Skip to content

SlowIsFast 博客项目上下文

项目基本信息

  • 框架:VitePress 1.6.x + Vue 3
  • 本地开发:npm run dev,端口 5000(用户有时访问 5003)
  • 构建:npm run build
  • GitHub:git@github.com-xiaomi:xiaomiyang/SlowIsFast.git(SSH别名 github.com-xiaomi)
  • 部署:Cloudflare Worker(wrangler deploy),域名 midoai.cn
  • 内容主题:巴菲特致股东信知识库 + 个人博客

目录结构

.vitepress/
  config.ts          # VitePress 配置,nav、socialLinks、buildEnd(RSS)
  rss.ts             # RSS 生成逻辑,产出 .vitepress/dist/feed.xml
  theme/
    index.ts         # 主题入口,注册全局组件
    custom.css       # 全局样式覆盖
    date.ts          # 日期格式化工具
    functions.ts     # initTags / initCategory / useYearSort
    serverUtils.ts   # getPosts(按日期倒序)、generatePaginationPages
    components/
      NewLayout.vue          # 主布局(doc-before: 日期+标签,doc-after: BacklinksSidebar)
      BacklinksSidebar.vue   # 右侧反链面板(DOM 提取 + 精准隐藏)
      GraphView.vue          # 知识图谱 D3 组件(fetch /graph-data.json)
      Tags.vue / Archives.vue / Category.vue / Page.vue / CommentGiscus.vue
pages/
  知识图谱.md          # 知识图谱 VitePress 页面(使用 GraphView 组件)
  巴菲特致股东信总览.md # 倒序索引(最新在前)
  核心思想索引.md / 人物索引.md / 公司索引.md
posts/
  berkshire/         # 巴菲特致股东信 1965-2024
  partnership/       # 合伙人信 1956-1970
  concepts/          # 投资概念
  companies/         # 公司分析
  people/            # 人物
  special/           # 特别信件
  draft/ trash/ private-notes/  # 生产环境排除
public/
  graph-data.json    # 知识图谱数据(nodes 219 / edges 3937)
  metadata.json      # 知识库元数据

关键 CSS 规则(custom.css)

  • 品牌色:--vp-c-brand: #2563eb(dark: #3b82f6)
  • markdown 链接:橙色 #c47f2a,hover #a0631a
  • 文章摘要(aside):position: fixed; left: 24px(移到左侧)
  • 右侧反链面板:position: fixed; right: 24px; top: 120px; max-height: calc(100vh-140px); overflow-y: auto; 宽度 160px; ≥1440px 显示
  • container max-width:60rem
  • 表格:有边框 + 隔行背景

重要约定与坑

  1. posts 内链接路径:指向 pages/ 的链接用 ../../pages/文件名.md(两级深)
    • 历史遗留 ../index-pages/ 已全部修正为 ../../pages/
  2. markdown 表格格式:必须有 | --- | 分隔行 + 行间无空行,已批量修复 53 个文件
  3. 反链块结构(posts 底部):每块 = <p>词条名 数字</p> + <p>内容+查看原文链接</p>(2个p),由 BacklinksSidebar.vue 提取并隐藏
  4. 知识图谱/graph.html(public/)在 VitePress dev 下 404,已迁移为 /pages/知识图谱 VitePress 原生页面
  5. 生产排除posts/draft/posts/trash/posts/private-notes/ 在 NODE_ENV=production 时不构建
  6. 图片资产:存放在 public/,VitePress 自动映射到根路径

部署配置

  • wrangler.tomlname=slow-is-fast[assets] directory=".vitepress/dist"
  • .node-version:20(Cloudflare 构建需要 Node 20,vite 7 要求)
  • package.json build script:vitepress build(无 cross-env)
  • 所有构建依赖在 dependencies(非 devDependencies),因为 Cloudflare 用 NODE_ENV=production

当前 master 分支最新状态(2026-04-07)

  • 知识图谱迁移完成(commit 455dc3c)
  • 全站 markdown 表格修复完成
  • posts 内 index-pages 断链修复完成
  • 右侧反链面板(相关概念列表)已实装
  • RSS 订阅已实装(/feed.xml)