-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsource.config.ts
More file actions
50 lines (46 loc) · 1.21 KB
/
source.config.ts
File metadata and controls
50 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import {
defineConfig,
defineDocs,
frontmatterSchema,
metaSchema,
} from 'fumadocs-mdx/config';
import { z } from 'zod';
import { remarkMermaid } from '@theguild/remark-mermaid';
import { visit } from 'unist-util-visit';
// Extend the frontmatter schema to include banner
const extendedFrontmatterSchema = frontmatterSchema.extend({
banner: z.string().optional(),
});
// You can customise Zod schemas for frontmatter and `meta.json` here
// see https://fumadocs.vercel.app/docs/mdx/collections#define-docs
export const docs = defineDocs({
docs: {
schema: extendedFrontmatterSchema,
},
meta: {
schema: metaSchema,
},
});
// Fix Mermaid components for fumadocs structure plugin
// The structure plugin expects components to have children, but Mermaid has a chart prop
function remarkFixMermaid() {
return (tree: any) => {
visit(tree, (node: any) => {
if (
node.type === 'mdxJsxFlowElement' &&
node.name === 'Mermaid' &&
!node.children
) {
node.children = [];
}
});
};
}
export default defineConfig({
mdxOptions: {
remarkPlugins: [
remarkMermaid,
remarkFixMermaid, // Fix Mermaid components after remarkMermaid runs
],
},
});