Skip to content

组件

用于增强文档的额外组件。

概览

你可以使用的额外组件:

MDX 组件

默认的 MDX 组件包括 Cards、Callouts、Code Blocks 和 Headings。

ts
import defaultMdxComponents from 'fumadocs-ui/mdx';

相对链接

WARNING

仅限 Server Component。

要在 href 中支持相对文件路径的链接,请用以下方式覆盖默认的 a 组件:

tsx
import { createRelativeLink } from 'fumadocs-ui/mdx';
import { source } from '@/lib/source';
import { getMDXComponents } from '@/components/mdx';

const page = source.getPage(['...']);

return (
  <MdxContent
    components={getMDXComponents({
      // 覆盖 `a` 标签
      a: createRelativeLink(source, page),
    })}
  />
);
mdx
[我的链接](./file.mdx)

示例:../../(integrations)/feedback.mdx

基于 VitePress 构建的 Fumadocs 中文文档