mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-20 22:44:25 +00:00
## 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.
84 lines
2.5 KiB
TypeScript
84 lines
2.5 KiB
TypeScript
import { generateAllDocParams, getPageImage, getPage, source } from '@/lib/source';
|
|
import {
|
|
DocsBody,
|
|
DocsPage,
|
|
DocsTitle,
|
|
} from 'fumadocs-ui/layouts/docs/page';
|
|
import { notFound } from 'next/navigation';
|
|
import { getMDXComponents } from '@/mdx-components';
|
|
import type { Metadata } from 'next';
|
|
import { createRelativeLink } from 'fumadocs-ui/mdx';
|
|
import { Callout } from 'fumadocs-ui/components/callout';
|
|
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
|
import { Feedback } from '@/components/feedback';
|
|
|
|
export default async function Page(props: any) {
|
|
const params = await props.params;
|
|
const { page, source: pageSource } = getPage(params.slug);
|
|
if (!page) notFound();
|
|
|
|
const MDX = page.data.body;
|
|
|
|
return (
|
|
<DocsPage toc={page.data.toc} full={page.data.full}>
|
|
<DocsTitle>{page.data.title}</DocsTitle>
|
|
<DocsBody>
|
|
<MDX
|
|
components={getMDXComponents({
|
|
Callout,
|
|
Tab,
|
|
Tabs,
|
|
// this allows you to link to other pages with relative file paths
|
|
a: createRelativeLink(pageSource, page),
|
|
})}
|
|
/>
|
|
</DocsBody>
|
|
<Feedback />
|
|
</DocsPage>
|
|
);
|
|
}
|
|
|
|
export const dynamicParams = false;
|
|
export const revalidate = false;
|
|
export const dynamic = 'force-static';
|
|
|
|
export async function generateStaticParams() {
|
|
return generateAllDocParams();
|
|
}
|
|
|
|
export async function generateMetadata(
|
|
props: any,
|
|
): Promise<Metadata> {
|
|
const params = await props.params;
|
|
const { page } = getPage(params.slug);
|
|
if (!page) notFound();
|
|
const baseUrl = 'https://zitadel.com/docs';
|
|
const url = params.slug ? `${baseUrl}/${params.slug.join('/')}` : baseUrl;
|
|
|
|
let canonicalUrl = url;
|
|
|
|
if (params.slug?.[0]?.startsWith('v')) {
|
|
const unversionedSlug = params.slug.slice(1);
|
|
const unversionedPage = source.getPage(unversionedSlug);
|
|
if (unversionedPage) {
|
|
canonicalUrl = `${baseUrl}${unversionedPage.url === '/' ? '' : unversionedPage.url}`;
|
|
}
|
|
}
|
|
|
|
let description = page.data.description;
|
|
if (!description) {
|
|
description = `Explore ZITADEL documentation for ${page.data.title}. Learn how to integrate, manage, and secure your applications with our comprehensive identity and access management solutions.`;
|
|
}
|
|
|
|
return {
|
|
title: page.data.title,
|
|
description: description.length > 200 ? description.substring(0, 197) + '...' : description,
|
|
alternates: {
|
|
canonical: canonicalUrl,
|
|
},
|
|
openGraph: {
|
|
images: getPageImage(page).url,
|
|
},
|
|
};
|
|
}
|