Repository navigation
Expand file tree
/
Copy pathsource.config.ts
More file actions
156 lines (145 loc) · 4.87 KB
/
Copy pathsource.config.ts
File metadata and controls
156 lines (145 loc) · 4.87 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import {
defineConfig,
defineDocs,
defineCollections,
frontmatterSchema,
getDefaultMDXOptions,
metaSchema,
type DefaultMDXOptions,
} from 'fumadocs-mdx/config';
import { remarkPlugins } from './lib/mdx-remark-plugins';
import rehypeKatex from 'rehype-katex';
import { z } from 'zod';
import { rehypeCodeDefaultOptions } from 'fumadocs-core/mdx-plugins';
import { transformerTwoslash } from 'fumadocs-twoslash';
import { indexedMdxAttribute, remarkCalloutLabels } from './lib/academy/remark-callout-labels';
import { transformerShellPrompt } from './lib/docs-book/shell-prompt';
const isDevelopment = process.env.NODE_ENV === 'development';
// MDX options for every collection. A collection's own mdxOptions replace these instead of
// extending them (fumadocs-mdx 13.0.8, dist/chunk-2E2JCOSO.js:97), so the Academy collection
// builds its options from this object and adds its callout marks.
const mdxOptions = {
// When the build host can't reach a remote image (DNS / VPN / offline),
// skip dimension probing instead of failing the whole MDX compile. Next.js
// <Image> may warn about missing dimensions in dev but won't break the page.
remarkImageOptions: {
onError: 'ignore',
},
rehypeCodeOptions: {
lazy: true,
langs: ['ts', 'js', 'html', 'tsx', 'mdx'],
inline: 'tailing-curly-colon',
themes: {
light: 'catppuccin-latte',
dark: 'catppuccin-mocha',
},
transformers: [
...(rehypeCodeDefaultOptions.transformers ?? []),
...(!isDevelopment ? [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');
}
},
},
// Marks shell command lines for the "$ " prompt that app/docs/book/code.css draws. It adds
// only a class, so collections without that CSS render as before. It runs after the notation
// transformers above, so it reads the lines that the reader sees (lib/docs-book/shell-prompt.ts).
transformerShellPrompt(),
],
},
remarkPlugins,
rehypePlugins: (v) => [rehypeKatex, ...v],
} satisfies DefaultMDXOptions;
export const { docs, meta } = defineDocs({
docs: {
async: true,
schema: frontmatterSchema.extend({
index: z.boolean().default(false),
edit_url: z.string().optional(),
}),
postprocess: {
includeProcessedMarkdown: !isDevelopment,
},
},
meta: {
schema: metaSchema.extend({
description: z.string().optional(),
}),
},
});
export const course = defineCollections({
type: 'doc',
dir: 'content/academy',
postprocess: {
includeProcessedMarkdown: !isDevelopment,
},
// Callouts get their kind and label marks, in this collection only; the marks stay
// out of the search index built from structuredData.
mdxOptions: getDefaultMDXOptions({
...mdxOptions,
remarkPlugins: [...remarkPlugins, remarkCalloutLabels],
remarkStructureOptions: { allowedMdxAttributes: indexedMdxAttribute },
}),
schema: frontmatterSchema.extend({
preview: z.string().optional(),
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;
}
}).optional(),
authors: z.array(z.string()).optional(),
comments: z.boolean().default(false),
}),
});
export const courseMeta = 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.union([z.string(), z.array(z.string())]),
available: z.array(z.string()).optional(),
logo: z.string().optional(),
developer: z.string().optional(),
website: z.string().optional(),
documentation: z.string().optional(),
baas_platform: z.string().optional(),
featured: z.boolean().default(false).optional()
}),
});
export const blog = defineCollections({
type: 'doc',
dir: 'content/blog',
postprocess: {
includeProcessedMarkdown: !isDevelopment,
},
schema: frontmatterSchema.extend({
authors: z.array(z.string()).optional(),
topics: z.array(z.string()).optional(),
date: z.union([z.iso.date(), z.date()]).optional(),
comments: z.boolean().default(false),
}),
});
export default defineConfig({
lastModifiedTime: isDevelopment ? undefined : 'git',
mdxOptions,
});