toMedia

Fumadocs MDX

将内容转换为类型安全数据的工具

Fumadocs MDX 是一个将内容转换为类型安全数据的工具,类似于 Content Collections。它不是一个完整的 CMS,而是一个内容处理层,用于处理 Markdown、MDX 文件以及博客文章等内容。

集合(Collections)

集合是特定文件类型的分组,在 source.config.ts 配置文件中定义。Fumadocs MDX 支持三种集合类型:

Doc 集合

将 Markdown 和 MDX 文件转换为 React Server Components,包含目录等属性。

source.config.ts
import { defineCollections } from 'fumadocs-mdx/config';

export const test = defineCollections({
  type: 'doc',
  dir: 'content/docs',
});

Meta 集合

将 YAML 和 JSON 文件处理为数据数组。

source.config.ts
import { defineCollections } from 'fumadocs-mdx/config';

export const test = defineCollections({
  type: 'meta',
  dir: 'content/docs',
});

Docs 集合

为 Fumadocs 集成而组合 meta 和 doc 集合。

source.config.ts
import { defineDocs } from 'fumadocs-mdx/config';

export const docs = defineDocs({
  dir: 'content/docs',
  docs: { /* 选项 */ },
  meta: { /* 选项 */ },
});

内置属性

MDX 文件自动导出以下属性:

属性用途
frontmatter元数据块内容
toc目录生成
structuredData搜索实现支持
extractedReferences链接引用分析

安装

Fumadocs MDX 支持多种框架集成,请参阅具体的集成指南。

子文档

On this page