配置
全局配置
Fumadocs MDX 全局配置选项
defineConfig 函数来自 fumadocs-mdx/config,通过 source.config.ts 中的全局选项自定义 Fumadocs MDX。
GlobalConfig 选项
plugins
- 类型:
PluginOption[] | undefined - 可选的功能扩展插件数组
mdxOptions
- 类型:
MDXPresetOptions | (() => Promise<MDXPresetOptions>) | undefined - 配置全局 MDX 选项,支持同步或异步配置
workspaces
- 类型:
Record<string, { dir: string; config: Record<string, unknown>; }> | undefined - 启用多工作区设置
experimentalBuildCache
- 类型:
string | undefined - 指定缓存目录(开发模式下禁用)。缓存不会自动更新,删除缓存文件夹即可清理。
MDX 选项配置
通过添加 remark 和 rehype 插件自定义默认 MDX 预设:
import { defineConfig } from 'fumadocs-mdx/config';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkMath],
rehypePlugins: (v) => [rehypeKatex, ...v],
},
});最小预设
使用最小预设仅接受 MDX 处理器选项:
export default defineConfig({
mdxOptions: {
preset: 'minimal',
},
});