-
Notifications
You must be signed in to change notification settings - Fork 396
/
Copy pathsource.config.ts
122 lines (113 loc) · 3.23 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import {
defineConfig,
defineDocs,
defineCollections,
frontmatterSchema,
metaSchema,
} from 'fumadocs-mdx/config';
import { rehypeCodeDefaultOptions, remarkImage } from 'fumadocs-core/mdx-plugins';
import { transformerTwoslash } from 'fumadocs-twoslash';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import { remarkHeading } from 'fumadocs-core/mdx-plugins';
import { z } from 'zod';
export const { docs, meta } = defineDocs({
docs: {
async: true,
schema: frontmatterSchema.extend({
preview: z.string().optional(),
toc: z.boolean().default(true),
index: z.boolean().default(false),
}),
},
meta: {
schema: metaSchema.extend({
description: z.string().optional(),
}),
},
});
export const academy = defineCollections({
type: 'doc',
async: true,
dir: 'content/academy',
schema: frontmatterSchema.extend({
preview: z.string().optional(),
toc: z.boolean().default(true),
index: z.boolean().default(false),
updated: z.string().or(z.date()).transform((value, context) => {
try {
return new Date(value);
} catch {
context.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid date" });
return z.NEVER;
}
}),
authors: z.array(z.string()),
comments: z.boolean().default(false),
}),
});
export const academyMeta = defineCollections({
type: 'meta',
dir: 'content/academy',
schema: metaSchema.extend({
description: z.string().optional(),
}),
});
export const integrations = defineCollections({
type: 'doc',
async: true,
dir: 'content/integrations',
schema: frontmatterSchema.extend({
category: z.string(),
available: z.array(z.string()).optional(),
logo: z.string().optional(),
developer: z.string().optional(),
website: z.string().optional(),
documentation: z.string().optional(),
featured: z.boolean().default(false).optional()
}),
});
export const guide = defineCollections({
type: 'doc',
async: true,
dir: 'content/guides',
schema: frontmatterSchema.extend({
authors: z.array(z.string()),
topics: z.array(z.string()),
date: z.string().date().or(z.date()).optional(),
comments: z.boolean().default(false),
}),
});
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) {
for (const line of hast.children) {
if (line.type !== 'element') continue;
const lastSpan = line.children.findLast(
(v) => v.type === 'element',
);
const head = lastSpan?.children[0];
if (head?.type !== 'text') return;
head.value = head.value.replace(/\[\\!code/g, '[!code');
}
},
},
],
},
remarkPlugins: [ remarkMath, remarkHeading, [remarkImage, { useImport: false }] ],
rehypePlugins: (v) => [rehypeKatex, ...v],
jsx: false,
},
});