标题
处理你的文档中的标题
备注标题
🌐 Remark Heading
将 ID 应用于标题。
🌐 Applies ids to headings.
import { compile } from '@mdx-js/mdx';
import { remarkHeading } from 'fumadocs-core/mdx-plugins';
await compile('...', {
remarkPlugins: [remarkHeading],
});这个插件默认包含在 Fumadocs MDX 中。
提取目录
🌐 Extract TOC
默认情况下,它会将文档的标题(目录)提取到 vfile.data.toc。你可以通过以下方式禁用它:
🌐 By default, it extracts the headings (table of contents) of a document to vfile.data.toc.
You can disable it with:
import { remarkHeading } from 'fumadocs-core/mdx-plugins';
export default {
remarkPlugins: [[remarkHeading, { generateToc: false }]],
};自定义 ID
🌐 Custom Ids [#custom-heading-id]
你可以使用 [#slug] 自定义标题 ID。
🌐 You can customise the heading id with [#slug].
# heading [#slug]输出
🌐 Output
一个 TOCItemType 数组。
🌐 An array of TOCItemType.
Prop
Type
Rehype 目录
🌐 Rehype TOC
导出目录表(一个 TOCItemType 数组),它允许使用 JSX 节点,这是 Remark 插件无法实现的。
🌐 Exports table of contents (an array of TOCItemType), it allows JSX nodes which is not possible with a Remark plugin.
它需要 MDX.js。
使用
🌐 Usage
import { rehypeToc } from 'fumadocs-core/mdx-plugins';
export default {
rehypePlugins: [rehypeToc],
};输出
🌐 Output
对于一个 Markdown 文档:
🌐 For a Markdown document:
## Hello `code`将创建一个导出文件:
🌐 An export will be created:
export const toc = [
{
title: (
<>
Hello <code>code</code>
</>
),
depth: 2,
url: '#hello-code',
},
];Last updated on
