概述
Fumadocs MDX v12 主要旨在统一 Vite 和 Next.js 上的 Fumadocs MDX。
它包含对某些 API 的重命名(导入路径不受影响),可能需要进行迁移。
重大变更
Next.js
从页面数据中移除 content,改为使用 getText()。
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.data.content);页面数据上的 API 重命名:
_file->info。_file.absolutePath->info.fullPath。
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page._file, page._file.absolutePath);改进
Vite
为 info 添加 API 以访问原始文件信息。
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.info);getText()
您可以使用它来访问:
- 原始 Markdown 内容。
- 在编译成 HAST (HTML) 之前处理的 Markdown。
这在使用文档生成工具和 remark 插件时,对于生成 llms.txt 很有用。
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(await page.data.getText('raw'));
console.log(await page.data.getText('processed'));要访问处理的 Markdown 内容,您需要在集合配置中启用 includeProcessedMarkdown。
import { defineDocs } from 'fumadocs-mdx/config';
export default defineDocs({
docs: {
postprocess: {
includeProcessedMarkdown: true,
},
},
});Written by
Fuma Nama
At
Sat Sep 20 2025