Written by
Fuma Nama
At
Sat Sep 20 2025
Fumadocs MDX v12
运行时改进与大型语言模型集成。
概览
🌐 Overview
Fumadocs MDX v12 主要旨在统一基于 Vite 和 Next.js 的 Fumadocs MDX。
🌐 Fumadocs MDX v12 mainly aims to unify Fumadocs MDX on Vite and Next.js.
它包含对某些 API 的重命名(导入路径不受影响),可能需要进行迁移。
🌐 It contains renames to certain APIs (import paths are unaffected), migrations may be necessary.
重大更改
🌐 Breaking Changes
Next.js
在页面数据中已移除 content,改为使用 getText()。
🌐 Removed content on page data in favour of getText().
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.data.content);页面数据上的 API 重命名:
🌐 API Renames on page data:
_file->info。_file.absolutePath->info.fullPath。
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page._file, page._file.absolutePath);改进
🌐 Improvements
Vite
为 info 添加了访问原始文件信息的 API。
🌐 Added APIs for info to access raw file info.
import { source } from '@/lib/source';
const page = source.getPage(['...']);
console.log(page.info);getText()
你可以用它来访问:
🌐 You can use it to access:
- 原始 Markdown 内容。
- 在编译成 HAST(HTML)之前处理过的 Markdown。
当与文档生成工具和 remark 插件一起使用时,这对于 llms.txt 的生成非常有用。
🌐 This is useful for llms.txt generation when used with docs generations tools & remark plugins.
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。
🌐 To access processed Markdown content, you need to enable includeProcessedMarkdown in collection config.
import { defineDocs } from 'fumadocs-mdx/config';
export default defineDocs({
docs: {
postprocess: {
includeProcessedMarkdown: true,
},
},
});