-
I want to disable TOC for some pages because it sometimes are useless, how i can do it? |
Beta Was this translation helpful? Give feedback.
Answered by
sheldygg
May 4, 2024
Replies: 1 comment
-
Okay, now i know how do it. In your source file you must create your custom frontmatter, and pass parameter for parsing. import {map} from '@/.map';
import {createMDXSource, defaultSchemas} from 'fumadocs-mdx';
import {loader} from 'fumadocs-core/source';
import {z} from 'zod';
const frontmatterSchema = defaultSchemas.frontmatter.extend({
disableToc: z.boolean().optional(),
});
export const {getPage, getPages, pageTree} = loader({
baseUrl: '/',
rootDir: '',
source: createMDXSource(map, {schema: {frontmatter: frontmatterSchema}}),
}); In your mdx file you must pass this parameter like this ---
title: ...
description: ...
disableToc: true
--- Finally in your page code you will be have this parameter in page.data. const toc = page.data.disableToc ? undefined : page.data.exports.toc;
return (
<DocsPage toc={toc}>
<DocsBody>
<h1>{page.data.title}</h1>
<MDX/>
</DocsBody>
</DocsPage>
); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sheldygg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay, now i know how do it.
In your source file you must create your custom frontmatter, and pass parameter for parsing.
Example of source file:
In your mdx file you must pass this parameter like this
Final…