chore: establish learning module baseline
This commit is contained in:
commit
2d04197f3f
2409 files changed
+533050
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
// DocsLayout (sidebar + nav) for prefixed-locale docs pages.
|
||||
export default async function Layout({
|
||||
children,
|
||||
params,
|
||||
}: LayoutProps<'/[lang]/[...slug]'>) {
|
||||
const { lang } = await params;
|
||||
return (
|
||||
<DocsLayout tree={source.getPageTree(lang)} {...baseOptions(lang)}>
|
||||
{children}
|
||||
</DocsLayout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { notFound } from 'next/navigation';
|
||||
import type { Metadata } from 'next';
|
||||
import { RenderDocsPage } from '@/components/docs-page';
|
||||
import { i18n } from '@/lib/i18n';
|
||||
|
||||
// Prefixed-locale docs page at /docs/<lang>/<slug> (requires >=1 slug segment,
|
||||
// so it never collides with the default-locale single-segment /[slug] route).
|
||||
export default async function Page(props: PageProps<'/[lang]/[...slug]'>) {
|
||||
const { lang, slug } = await props.params;
|
||||
return <RenderDocsPage slug={slug} lang={lang} />;
|
||||
}
|
||||
|
||||
export function generateStaticParams() {
|
||||
// Every NON-default locale × every slug.
|
||||
const langs = i18n.languages.filter((l) => l !== i18n.defaultLanguage);
|
||||
const params: { lang: string; slug: string[] }[] = [];
|
||||
for (const lang of langs) {
|
||||
for (const page of source.getPages(lang)) {
|
||||
params.push({ lang, slug: page.slugs });
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
export async function generateMetadata(
|
||||
props: PageProps<'/[lang]/[...slug]'>,
|
||||
): Promise<Metadata> {
|
||||
const { lang, slug } = await props.params;
|
||||
const page = source.getPage(slug, lang);
|
||||
if (!page) notFound();
|
||||
return { title: page.data.title, description: page.data.description };
|
||||
}
|
||||
Reference in new issue
Block a user