Files
zitadel/apps/docs/source.config.ts
Florian ForsterandGitHub 24d0f34f39 perf: optimize docs static generation cost (#12108)
## Summary
- Switch the docs catch-all route to full static generation and prebuild
both latest and versioned docs paths.
- Prebuild OG images for all docs pages, make sitemap and LLM export
static, and remove nondeterministic sitemap timestamps.
- Reduce build-time overhead by memoizing docs sidebar trees and
skipping processed markdown generation for versioned docs.

## Testing
- `pnpm nx run @zitadel/docs:build`
- `pnpm nx run @zitadel/docs:lint`
- `pnpm nx run @zitadel/docs:check-types`
- Verified the prerender manifest contains 8,816 prerendered routes,
3,293 versioned docs routes, 4,406 OG routes, and zero revalidating docs
routes.
2026-04-27 15:34:00 +00:00

70 lines
1.9 KiB
TypeScript

// Suppress MaxListenersExceededWarning from fumadocs-mdx internal concurrency
if (typeof process !== 'undefined') {
process.setMaxListeners(30);
}
import {
defineConfig,
defineDocs,
frontmatterSchema,
metaSchema,
} from 'fumadocs-mdx/config';
import { z } from 'zod';
// @ts-ignore
import remarkHeadingId from 'remark-heading-id';
// You can customise Zod schemas for frontmatter and `meta.json` here
// see https://fumadocs.dev/docs/mdx/collections
export const docs = defineDocs({
dir: 'content',
docs: {
schema: frontmatterSchema.extend({
sidebar_label: z.string().optional(),
}),
files: ['**/*.md', '**/*.mdx', '!v*/**/*', '!**/_*'], // Exclude versioned folders at root and partials
postprocess: {
includeProcessedMarkdown: true,
},
},
meta: {
schema: metaSchema,
files: ['**/meta.json', '!v*/**'],
},
});
export const versions = defineDocs({
dir: 'content',
docs: {
schema: frontmatterSchema.extend({
sidebar_label: z.string().optional(),
}),
files: ['v*/**/*.md', 'v*/**/*.mdx', '!**/_*'], // Include only versioned folders from content
},
meta: {
schema: metaSchema,
files: ['v*/meta.json', 'v*/**/meta.json'],
},
});
export default defineConfig({
mdxOptions: {
remarkPlugins: [[remarkHeadingId, { defaults: true }]],
rehypeCodeOptions: {
themes: {
light: 'github-light',
dark: 'github-dark',
},
langs: ['json', 'yaml', 'bash', 'sh', 'shell', 'http', 'nginx', 'dockerfile', 'go', 'python', 'javascript', 'typescript', 'tsx', 'jsx', 'css', 'html', 'csharp', 'java', 'xml', 'sql', 'properties', 'ini', 'diff', 'markdown', 'mdx'],
// Map unknown languages to text or similar
langAlias: {
'env': 'bash',
'curl': 'bash',
'caddy': 'nginx',
'conf': 'nginx',
'HTTP': 'http',
'JSON': 'json',
},
},
},
});