-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.config.ts
78 lines (72 loc) · 2.03 KB
/
source.config.ts
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {
defineConfig,
defineDocs,
defineCollections,
frontmatterSchema,
metaSchema,
} from 'fumadocs-mdx/config';
import { rehypeCodeDefaultOptions } from 'fumadocs-core/mdx-plugins';
import { transformerTwoslash } from 'fumadocs-twoslash';
import remarkMath from 'remark-math';
import { fileGenerator, remarkDocGen, remarkInstall } from 'fumadocs-docgen';
import rehypeKatex from 'rehype-katex';
import { z } from 'zod';
export const { docs, meta } = defineDocs({
docs: {
async: true,
schema: frontmatterSchema.extend({
preview: z.string().optional(),
index: z.boolean().default(false),
method: z.string().optional(),
}),
},
meta: {
schema: metaSchema.extend({
description: z.string().optional(),
}),
},
});
export const blog = defineCollections({
dir: 'content/blog',
schema: frontmatterSchema.extend({
author: z.string(),
date: z.string().date().or(z.date()).optional(),
}),
type: 'doc',
});
export default defineConfig({
lastModifiedTime: 'git',
mdxOptions: {
rehypeCodeOptions: {
inline: 'tailing-curly-colon',
themes: {
light: 'catppuccin-latte',
dark: 'catppuccin-mocha',
},
transformers: [
...(rehypeCodeDefaultOptions.transformers ?? []),
transformerTwoslash(),
{
name: 'transformers:remove-notation-escape',
code(hast: any) {
for (const line of hast.children) {
if (line.type !== 'element') continue;
const lastSpan = line.children.findLast(
(v: any) => v.type === 'element',
);
const head = lastSpan?.children[0];
if (head?.type !== 'text') return;
head.value = head.value.replace(/\[\\!code/g, '[!code');
}
},
},
],
},
remarkPlugins: [
remarkMath,
[remarkInstall, { persist: { id: 'package-manager' } }],
[remarkDocGen, { generators: [fileGenerator()] }],
],
rehypePlugins: (v) => [rehypeKatex, ...v],
},
});