返回 CodeWhale
layout.tsx
根目录 / web / app / [locale] / docs / layout.tsx
1 import { DocsArticleSearch } from "@/components/docs-search";
2 import { DocsCopyMarkdown } from "@/components/docs-copy-markdown";
3 import { EnglishRegion } from "@/components/fallback-region";
4 import { DocsBreadcrumb } from "@/components/docs-breadcrumb";
5 import { DocsHelp } from "@/components/docs-help";
6 import { DocsLanguageRegion } from "@/components/docs-language-region";
7 import { DocsSidebar } from "@/components/docs-sidebar";
8 import { ReleaseTruth } from "@/components/release-truth";
9 import { BUILD_FACTS, getFactsWithProvenance } from "@/lib/facts";
10 import { getHome } from "@/lib/i18n/dictionaries";
11 import { docsChromeFallsBackToEnglish, docsEnglishTopics } from "@/lib/i18n/fallback";
12 import { RELEASE_DOCS } from "@/lib/release-docs";
13
14 /* ------------------------------------------------------------------ */
15 /* Layout (Next.js App Router) */
16 /* ------------------------------------------------------------------ */
17
18 /**
19 * The docs shell every documentation URL shares: the breadcrumb, the
20 * version-aware release-truth line, the content + sidebar grid, and the contextual help band that closes each page. All copy is
21 * dictionary-driven; the release line reads the facts layer.
22 */
23 export default async function DocsLayout({
24 children,
25 params,
26 }: {
27 children: React.ReactNode;
28 params: Promise<{ locale: string }>;
29 }) {
30 const { locale } = await params;
31 // These pages describe THIS build: pin the documented facts to the build
32 // snapshot even when the KV snapshot was written by a newer source (a
33 // rollback, or any deployment sharing it). Only the latest published
34 // release is the KV snapshot's to speak for.
35 const resolution = await getFactsWithProvenance();
36 const facts = {
37 ...BUILD_FACTS,
38 latestPublishedRelease: resolution.facts.latestPublishedRelease,
39 };
40
41 const chromeEnglish = docsChromeFallsBackToEnglish(locale);
42 const markdownSlugs = RELEASE_DOCS.topics.map((topic) => topic.slug);
43
44 return (
45 <div className="docs-theme docs-portal min-h-screen">
46 <div className="portal-container docs-shell min-w-0">
47 <article className="docs-content min-w-0">
48 <EnglishRegion when={chromeEnglish}>
49 <DocsBreadcrumb locale={locale} />
50 <ReleaseTruth locale={locale} facts={facts} />
51 <DocsArticleSearch locale={locale} />
52 <DocsCopyMarkdown locale={locale} availableSlugs={markdownSlugs} copiedLabel={getHome(locale).copied} />
53 </EnglishRegion>
54 <DocsLanguageRegion locale={locale} englishTopics={docsEnglishTopics(locale)}>
55 {children}
56 </DocsLanguageRegion>
57 <EnglishRegion when={chromeEnglish}>
58 <DocsHelp locale={locale} />
59 </EnglishRegion>
60 </article>
61 <EnglishRegion when={chromeEnglish}>
62 <DocsSidebar locale={locale} />
63 </EnglishRegion>
64 </div>
65 </div>
66 );
67 }
68
68 lines Plain Text