跳至內容
Fumadocs

內嵌目錄

在您的文件中加入內嵌目錄

Install to your codebase

Easier customization & control.

npx @fumadocs/cli@latest add inline-toc

使用方式

您可以在 MDX 內容中使用它。在 Fumadocs MDX 的 MDX 檔案中,匯出的 toc 是一個以頁面 props 為參數的函式:

content.mdx
import { InlineTOC } from 'fumadocs-ui/components/inline-toc';

<InlineTOC items={toc(props)}>Table of Contents</InlineTOC>

或是將它加入每個頁面。

page.tsx
import { DocsPage } from 'fumadocs-ui/layouts/docs/page';
import { InlineTOC } from 'fumadocs-ui/components/inline-toc';

export default function Page() {
  // ...
  return (
    <DocsPage>
      <InlineTOC items={page.data.toc}>Table of Contents</InlineTOC>
    </DocsPage>
  );
}

參考資料

屬性

型別

How is this guide?

最後更新於