-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathsource.config.ts
More file actions
94 lines (87 loc) · 2.42 KB
/
source.config.ts
File metadata and controls
94 lines (87 loc) · 2.42 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { rehypeCodeDefaultOptions } from 'fumadocs-core/mdx-plugins';
import { remarkInstall } from 'fumadocs-docgen';
import { defineConfig, defineDocs, frontmatterSchema, metaSchema } from 'fumadocs-mdx/config';
import { transformerTwoslash } from 'fumadocs-twoslash';
import remarkDirective from 'remark-directive';
import { z } from 'zod';
import { remarkTooltip } from './src/lib/remark-tooltip';
export const docs = defineDocs({
dir: 'content/docs',
docs: {
files: ['**/*.mdx', '!**/*.model.mdx'],
schema: frontmatterSchema.extend({
preview: z.string().optional(),
index: z.boolean().default(false),
pageTitle: z.string().optional(),
/**
* API routes only
*/
method: z.string().optional(),
}),
},
meta: {
schema: metaSchema.extend({
description: z.string().optional(),
pageTitle: z.string().optional(),
}),
},
});
export default defineConfig({
lastModifiedTime: 'git',
mdxOptions: {
rehypeCodeOptions: {
lazy: true,
experimentalJSEngine: true,
langs: [
'ts',
'js',
'html',
'tsx',
'mdx',
'json',
'bash',
'php',
'csharp',
'python',
'ruby',
'go',
'java',
'kotlin',
'swift',
],
inline: 'tailing-curly-colon',
themes: {
light: 'github-light',
dark: 'github-dark',
},
transformers: [
...(rehypeCodeDefaultOptions.transformers ?? []),
transformerTwoslash(),
{
name: 'transformers:remove-notation-escape',
preprocess(code: string) {
return code;
},
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
code(hast: any) {
for (const line of hast.children) {
if (line.type !== 'element') continue;
const lastSpan = line.children.findLast(
(v: { type: string }) => v.type === 'element'
);
const head = lastSpan?.children[0];
if (head?.type !== 'text') return;
head.value = head.value.replace(/\[\\!code/g, '[!code');
}
},
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
} as any,
],
},
remarkPlugins: [
remarkDirective,
remarkTooltip,
[remarkInstall, { persist: { id: 'package-manager' } }],
],
},
});