返回 CodeWhale
getting-started-steps.tsx
根目录 / web / components / getting-started-steps.tsx
1 /**
2 * <GettingStartedSteps> — renders the shared new-user path from
3 * web/lib/content/getting-started.ts: install → provider connection →
4 * first task → verify the answer → optional Fleet setup.
5 *
6 * Used by the homepage and the /docs/guide page so the path reads
7 * identically in both places. Server component, SSG-safe.
8 */
9
10 import Link from "next/link";
11 import { OnboardingCheck } from "./onboarding-check";
12 import { GETTING_STARTED_STEPS } from "@/lib/content/getting-started";
13 import { getHome, pickText } from "@/lib/i18n/dictionaries";
14 import { InstallCodeBlock } from "./install-code-block";
15 import { Icon } from "./icon";
16
17 export function GettingStartedSteps({
18 locale = "en",
19 headingLevel = 3,
20 }: {
21 locale?: string;
22 /** 2 when the steps sit directly under the page title, 3 under a section. */
23 headingLevel?: 2 | 3;
24 }) {
25 const home = getHome(locale);
26 const StepHeading = headingLevel === 2 ? "h2" : "h3";
27 const renderStep = (step: (typeof GETTING_STARTED_STEPS)[number], index: number) => (
28 <li key={step.id} id={step.id} data-step-id={step.id} className="scroll-mt-32">
29 {!step.optional && <span className="gs-step-index" aria-hidden="true">{index + 1}</span>}
30 <StepHeading className="gs-step-title">{pickText(step.title, locale)}</StepHeading>
31 <p>{pickText(step.body, locale)}</p>
32 {step.commands.length > 0 && (
33 <InstallCodeBlock cmd={step.commands.join("\n")} copyLabel={home.copy} copiedLabel={home.copied} copyLocale={locale} installIntent={step.id === "install"} />
34 )}
35 {step.prompt && <InstallCodeBlock cmd={pickText(step.prompt, locale)} copyLabel={home.copy} copiedLabel={home.copied} copyLocale={locale} installIntent={false} />}
36 {step.id === "verify-answer" && <OnboardingCheck kind="quickstart" locale={locale} />}
37 <Link href={`/${locale}${step.link.href}`} className="gs-step-link">
38 {pickText(step.link.label, locale)}
39 <Icon name="arrow-right" className="icon icon-flip" />
40 </Link>
41 </li>
42 );
43 return (
44 <div className="space-y-8">
45 <ol className="gs-steps">{GETTING_STARTED_STEPS.filter((step) => !step.optional).map(renderStep)}</ol>
46 <aside className="hairline-t pt-6">
47 <ul className="gs-steps !grid-cols-1">{GETTING_STARTED_STEPS.filter((step) => step.optional).map(renderStep)}</ul>
48 </aside>
49 </div>
50 );
51 }
52
52 lines Plain Text