文档、博客与法律内容

使用 Fumadocs MDX 编写文档、博客文章和法律页面。

模板使用 Fumadocs 从 MDX 编译文档、博客与法律页。Collection schema 位于 source.config.ts,应用 loader 再把生成模块转换为可序列化路由数据与延迟渲染 内容。

内容目录

source.config.ts

模板内置了一套可直接定制的产品文档站点。初始导航将页面分为 introductionessentialscomponents;你可以根据自己的 SaaS 替换、 重命名或重新组织这些栏目。每个目录中的 meta.json 控制栏目标题与页面顺序; 只有对应 MDX 文件存在后,才把文件名加入 pages

文档

defineDocs({ dir: "content/docs" }) 定义 collection。src/lib/source.ts 用 Vite glob 加载 MDX/metadata,配置 Fumadocs 中英文与语言路径。_docs.tsxcreateServerFn 中序列化 page tree;_docs/docs/$.tsx 解析 catch-all 页面、预加载 MDX、注入 Fumadocs component 并构建 SEO。

默认语言用 slug.mdx,中文用 slug.zh.mdx。模板目前只在 introduction/quick-start 演示成对文件;多数其他文档仍只有英文,因此补齐前 不要宣称文档已完全双语。

---
title: API Overview
description: Learn how the product API is organized.
icon: Braces
---

## Authentication

Explain the endpoint here.

新增 api-overview.mdxapi-overview.zh.mdx,再把 "api-overview" 放进对应 meta.json

博客

source.config.ts 要求 titledate;description、author、tags、image 可选。 src/lib/blog.ts 加载文章、按日期倒序、从路径生成 slug、每页六篇,并生成最多 十个标签(先按频次,再按名称排序)。

---
title: Shipping the First Release
description: What changed and how to upgrade.
date: 2026-06-24
author: Example Team
tags: [Release, Product]
image: /screen/release.png
---

Write the post here.

_marketing/blog/index.tsx 校验 tag/page query 并加载筛选列表; _marketing/blog/$slug.tsx 加载单篇文章、渲染 TOC 与 metadata,未知 slug 返回 not found。

法律页

法律 frontmatter 要求 titledatedescription 可选,published 默认 true

---
title: Acceptable Use Policy
description: Rules for using the service.
date: 2026-06-24
published: true
---

src/lib/legal.ts 会从直接查询和 sitemap 枚举中排除未发布页面; _marketing/legal/$slug.tsx 渲染正文与 TOC。应根据产品实际情况和专业意见更新 法律文案、日期、链接与司法辖区。

本地化边界

文档识别语言文件后缀。博客和法律 loader 当前在 /.../zh/... 共用一个 collection;翻译路由外壳不会自动翻译正文。若两者也要双语,应扩展 schema/loader 的 locale 字段或文件名约定,按路由语言选择内容,并生成正确 SEO alternate。

生成文件与构建

fumadocs-mdx Vite 插件读取 source.config.ts,在 .source 生成类型模块。该目录 由 TypeScript 包含但被 gitignore;不要手改或提交。生成 import 过期时,停止 dev server,必要时删除生成缓存,再运行 pnpm devpnpm build

验证

  • 新文档在两个语言的 meta.json 预期顺序中出现。
  • 缺少语言版本时有明确 fallback,或已补齐。
  • 博客按日期排序、可按标签筛选和分页,并渲染 TOC/SEO。
  • published: false 法律页返回 not found 且不进入 sitemap。
  • 内部链接使用语言感知应用路径。
  • pnpm build 重新生成 .source 并编译全部 MDX。

相关页面

On this page