forked from langfuse/langfuse-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.config.ts
More file actions
181 lines (158 loc) · 5.6 KB
/
source.config.ts
File metadata and controls
181 lines (158 loc) · 5.6 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import { defineDocs, defineConfig, frontmatterSchema } from "fumadocs-mdx/config";
import remarkGfm from "remark-gfm";
import { remarkMdxMermaid } from "fumadocs-core/mdx-plugins";
import { mdxJsxToMarkdown } from "mdast-util-mdx-jsx";
import { z } from "zod";
// YAML parses unquoted dates (e.g. `date: 2023-07-19`) as JS Date objects.
// Use this helper so both string dates and Date objects are accepted and
// normalised to an ISO date string (YYYY-MM-DD).
const yamlDateField = z
.union([
z.string(),
z.date().transform((d) => d.toISOString().split("T")[0]),
])
.nullish();
// Base schema that adds canonical and noindex to the default frontmatter schema.
// All per-collection schemas should extend this so these fields are always parsed.
const baseFrontmatterSchema = frontmatterSchema.extend({
canonical: z.string().nullish(),
noindex: z.boolean().nullish(),
// Optional SEO title override: when set, used for <title> and OG title
// instead of the navigation title (keeps sidebar labels short).
seoTitle: z.string().nullish(),
// Optional per-page OG image override (site-relative path, e.g. /images/foo.jpg).
// When set, used instead of the generated /api/og card.
ogImage: z.string().nullish(),
});
// Extended schema for blog pages — adds date, tag, author, ogImage fields
// used by BlogIndex for thumbnails and filtering.
const blogFrontmatterSchema = baseFrontmatterSchema.extend({
date: yamlDateField,
tag: z.string().nullish(),
author: z.string().nullish(),
showInBlogIndex: z.boolean().nullish(),
});
// Extended schema for changelog pages — adds date, author, ogImage, ogVideo, badge
// that the Changelog widget and ChangelogHeader read from frontMatter.
const changelogFrontmatterSchema = baseFrontmatterSchema.extend({
date: yamlDateField,
author: z.string().nullish(),
ogVideo: z.string().nullish(),
gif: z.string().nullish(),
badge: z.string().nullish(),
});
// Extended schema for customer story pages — preserves all default fields and
// adds the custom frontmatter fields used by CustomerCarousel / CustomerIndex.
const customerFrontmatterSchema = baseFrontmatterSchema.extend({
// Use .nullish() so empty YAML values (parsed as null) are accepted too
date: yamlDateField,
tag: z.string().nullish(),
author: z.string().nullish(),
customerLogo: z.string().nullish(),
customerLogoDark: z.string().nullish(),
customerQuote: z.string().nullish(),
quoteAuthor: z.string().nullish(),
quoteRole: z.string().nullish(),
quoteCompany: z.string().nullish(),
quoteAuthorImage: z.string().nullish(),
showInCustomerIndex: z.boolean().nullish(),
});
// remarkPlugins is applied globally in defineConfig; per-collection mdxOptions
// are only needed for schema customization.
export const docs = defineDocs({
dir: "content/docs",
docs: { schema: baseFrontmatterSchema },
});
const selfHostingFrontmatterSchema = baseFrontmatterSchema.extend({
sidebarTitle: z.string().nullish(),
label: z.string().nullish(),
});
export const selfHosting = defineDocs({
dir: "content/self-hosting",
docs: {
schema: selfHostingFrontmatterSchema,
},
});
export const blog = defineDocs({
dir: "content/blog",
docs: {
schema: blogFrontmatterSchema,
},
});
export const changelog = defineDocs({
dir: "content/changelog",
docs: {
schema: changelogFrontmatterSchema,
},
});
const guidesFrontmatterSchema = baseFrontmatterSchema.extend({
category: z.string().nullish(),
});
export const guides = defineDocs({
dir: "content/guides",
docs: {
schema: guidesFrontmatterSchema,
},
});
const faqFrontmatterSchema = baseFrontmatterSchema.extend({
tags: z.array(z.string()).optional(),
});
export const faq = defineDocs({
dir: "content/faq",
docs: {
schema: faqFrontmatterSchema,
},
});
const integrationsFrontmatterSchema = baseFrontmatterSchema.extend({
sidebarTitle: z.string().nullish(),
logo: z.string().nullish(),
});
export const integrations = defineDocs({
dir: "content/integrations",
docs: {
schema: integrationsFrontmatterSchema,
},
});
export const security = defineDocs({
dir: "content/security",
docs: { schema: baseFrontmatterSchema },
});
export const library = defineDocs({
dir: "content/library",
docs: { schema: baseFrontmatterSchema },
});
export const customers = defineDocs({
dir: "content/customers",
docs: {
schema: customerFrontmatterSchema,
},
});
export const handbook = defineDocs({
dir: "content/handbook",
docs: { schema: baseFrontmatterSchema },
});
export const marketing = defineDocs({
dir: "content/marketing",
docs: { schema: baseFrontmatterSchema },
});
export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkGfm, remarkMdxMermaid],
providerImportSource: "@/mdx-components",
// Disable remark-image: many content files reference remote images via https://
// and the plugin tries to fetch dimensions at compile time, causing build failures
remarkImageOptions: false,
// Teach remark-structure's mdast-util-to-markdown serializer how to handle
// MDX JSX nodes (mdxJsxFlowElement / mdxJsxTextElement). Without this, it
// throws "Cannot handle unknown node `mdxJsxFlowElement`" when pages contain
// JSX components like <Callout>, <Tabs>, etc.
remarkStructureOptions: {
// @ts-ignore — extensions is valid in mdast-util-to-markdown but the
// StructureOptions type doesn't expose it directly
stringify: { extensions: [mdxJsxToMarkdown()] },
},
// @ts-ignore — { lazy: false } is valid at runtime; RehypeCodeOptions
// requires themes in its full type but fumadocs applies safe defaults
rehypeCodeOptions: { lazy: false },
},
});