返回 CodeWhale
page.tsx
根目录 / web / app / [locale] / docs / configuration / page.tsx
1 import { Fragment } from "react";
2 import { getDocsConfiguration, splitTokens } from "@/lib/i18n/dictionaries";
3 import { buildPageMetadata } from "@/lib/page-meta";
4
5 const CODE_SPANS: Record<string, string> = {
6 auditCommand: "/config audit",
7 apiKey: "--api-key",
8 authStatus: "codewhale auth status",
9 providerConfig: 'provider = "<id>"',
10 providerFlag: "codewhale --provider <id>",
11 };
12
13 function RichCopy({ text }: { text: string }) {
14 return splitTokens(text).map((part, i) =>
15 "token" in part ? (
16 <code key={`${i}-${part.token}`} className="inline">
17 {CODE_SPANS[part.token] ?? `{${part.token}}`}
18 </code>
19 ) : (
20 <Fragment key={`${i}-text`}>{part.text}</Fragment>
21 ),
22 );
23 }
24
25 export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
26 const { locale } = await params;
27 const t = getDocsConfiguration(locale);
28 return buildPageMetadata({
29 path: "/docs/configuration",
30 locale,
31 title: t.metaTitle,
32 description: t.metaDescription,
33 });
34 }
35
36 export default async function ConfigurationPage({
37 params,
38 }: {
39 params: Promise<{ locale: string }>;
40 }) {
41 const { locale } = await params;
42 const t = getDocsConfiguration(locale);
43
44 return (
45 <section className="space-y-10">
46 <section id="overview" className="scroll-mt-32">
47 <h1 className="font-display text-3xl mb-1">{t.overviewTitle}</h1>
48 <p className={`${t.bodyClassName} mt-3`}>{t.overviewLead}</p>
49 <pre className="code-block mt-4">{`codewhale --config /path/to/config.toml
50 CODEWHALE_CONFIG_PATH=/path/to/config.toml`}</pre>
51 <p className={`${t.bodyClassName} mt-3`}>
52 <RichCopy text={t.auditLead} />
53 </p>
54 </section>
55
56 <section id="project-overlay" className="scroll-mt-32">
57 <h2 className="font-display text-2xl mb-1">{t.overlayTitle}</h2>
58 <p className={`${t.bodyClassName} mt-3`}>{t.overlayLead}</p>
59 <p className={`${t.bodyClassName} mt-3`}>{t.overlayLimits}</p>
60 </section>
61
62 <section id="credentials" className="scroll-mt-32">
63 <h2 className="font-display text-2xl mb-1">{t.credentialsTitle}</h2>
64 <p className={`${t.bodyClassName} mt-3`}>
65 <RichCopy text={t.credentialsLead} />
66 </p>
67 </section>
68
69 <section id="legacy-paths" className="scroll-mt-32">
70 <h2 className="font-display text-2xl mb-1">{t.legacyTitle}</h2>
71 <p className={`${t.bodyClassName} mt-3`}>{t.legacyLead}</p>
72 </section>
73
74 <section id="source" className="hairline-t pt-8">
75 <p className="text-sm text-ink-mute">{t.sourceNote}</p>
76 </section>
77 </section>
78 );
79 }
80
80 lines Plain Text