-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsource.config.ts
More file actions
96 lines (91 loc) · 2.76 KB
/
Copy pathsource.config.ts
File metadata and controls
96 lines (91 loc) · 2.76 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
import { defineDocs, defineConfig } from "fumadocs-mdx/config";
import remarkTabsSyntax from "./plugins/remark-tabs-syntax";
import remarkCodeGroupToTabs from "./plugins/remark-codegroup-to-tabs";
import remarkCodeLanguage from "./plugins/remark-code-language";
import remarkImagePaths from "./plugins/remark-image-paths";
import remarkLinkPaths from "./plugins/remark-link-paths";
import remarkFollowExport from "./plugins/remark-follow-export";
import remarkDirective from "remark-directive";
import { remarkInclude } from "fumadocs-mdx/config";
import remarkSdkFilter from "./plugins/remark-sdk-filter";
import remarkMarkdownImageMap from "./plugins/remark-markdown-image-map";
import remarkVisibility from "./plugins/remark-visibility";
import type { LLMsOptions } from "fumadocs-core/mdx-plugins";
const isDevelopment = process.env.NODE_ENV === "development";
const markdownHeadingHandler: NonNullable<LLMsOptions["handlers"]>["heading"] = (
node,
_parent,
state,
info,
) => {
const depth = Math.min(Math.max(node.depth, 1), 6);
return `${"#".repeat(depth)} ${state.containerPhrasing(node, info)}`;
};
const processedMarkdownOptions: LLMsOptions = {
handlers: {
heading: markdownHeadingHandler,
},
mdxAsPlaceholder: [
"Accordion",
"AccordionGroup",
"Callout",
"Card",
"CardGroup",
"CodeGroup",
"Frame",
"Info",
"Mermaid",
"Note",
"Step",
"Steps",
"Tab",
"Tabs",
"Tip",
"Visibility",
"Warning",
],
};
const markdownImageMapPassthroughPlugin = {
"index-file": {
serverOptions(options: any) {
options.doc ??= {};
options.doc.passthroughs ??= [];
options.doc.passthroughs.push("markdownImageMap");
},
},
};
export const docs = defineDocs({
dir: "content/docs",
docs: {
async: isDevelopment,
postprocess: {
includeProcessedMarkdown: processedMarkdownOptions,
},
},
});
export default defineConfig({
plugins: [markdownImageMapPassthroughPlugin],
mdxOptions: {
// Shiki highlighting is one of the most expensive parts of the MDX pipeline.
// Keep it in builds, but skip it in local dev so first-page SSR doesn't have
// to highlight hundreds of code-heavy docs up front.
rehypeCodeOptions: isDevelopment ? false : undefined,
remarkPlugins: (existing) => [
remarkImagePaths,
remarkMarkdownImageMap,
remarkLinkPaths,
remarkFollowExport,
// Strip agent-only content before Fumadocs captures structured search data.
remarkVisibility,
...existing,
remarkInclude,
remarkDirective,
// Keep the transform idempotent for content changed by later local plugins.
remarkVisibility,
remarkTabsSyntax,
remarkCodeLanguage,
remarkCodeGroupToTabs,
remarkSdkFilter,
],
},
});