返回 CodeWhale
page.tsx
根目录 / web / app / [locale] / contribute / page.tsx
1 import Link from "next/link";
2 import { Icon } from "@/components/icon";
3 import { PageHeader, Section } from "@/components/page-header";
4 import { getContribute, pickTextLocale } from "@/lib/i18n/dictionaries";
5 import { buildPageMetadata } from "@/lib/page-meta";
6 import { getMerchCopy } from "@/lib/content/contributor-merch";
7
8 export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
9 const { locale } = await params;
10 const t = getContribute(locale);
11 return buildPageMetadata({
12 path: "/contribute",
13 locale,
14 title: t.metaTitle,
15 description: t.metaDescription,
16 });
17 }
18
19 const stepsEn = [
20 {
21 n: "01",
22 title: "Choose one clear problem",
23 body: "Browse open issues, especially good first issue and help wanted. If the behavior is not tracked yet, open an issue with a reproduction before starting a large change.",
24 cta: { label: "Browse open issues", href: "https://github.com/codewhale-hq/CodeWhale/issues" },
25 },
26 {
27 n: "02",
28 title: "Fork and create a branch",
29 body: "Clone your fork and use a short branch name such as fix/provider-timeout or docs/fleet-example. Keep unrelated changes in separate pull requests.",
30 cta: { label: "Open the repository", href: "https://github.com/codewhale-hq/CodeWhale" },
31 },
32 {
33 n: "03",
34 title: "Test the behavior you changed",
35 body: "Run the smallest relevant test first, then formatting and the broader checks required for the part of the repository you touched.",
36 cta: { label: "Read the contributor guide", href: "https://github.com/codewhale-hq/CodeWhale/blob/main/CONTRIBUTING.md" },
37 },
38 {
39 n: "04",
40 title: "Explain the result in the PR",
41 body: "Describe the problem, the reason for the change, the checks you ran, and any remaining risk. Link the issue when one exists.",
42 cta: { label: "View open pull requests", href: "https://github.com/codewhale-hq/CodeWhale/pulls" },
43 },
44 ];
45
46 const stepsZh = [
47 {
48 n: "01",
49 title: "选择一个明确的问题",
50 body: "先浏览 open issues,尤其是 good first issue 和 help wanted。如果问题尚未记录,请在开始大改动前提交带复现步骤的 issue。",
51 cta: { label: "浏览 open issues", href: "https://github.com/codewhale-hq/CodeWhale/issues" },
52 },
53 {
54 n: "02",
55 title: "Fork 并创建分支",
56 body: "克隆你的 fork,并使用简短的分支名,例如 fix/provider-timeout 或 docs/fleet-example。无关修改请拆成不同的 pull request。",
57 cta: { label: "打开仓库", href: "https://github.com/codewhale-hq/CodeWhale" },
58 },
59 {
60 n: "03",
61 title: "测试你修改的行为",
62 body: "先运行最小相关测试,再执行格式检查和你所修改部分需要的更完整检查。",
63 cta: { label: "阅读贡献指南", href: "https://github.com/codewhale-hq/CodeWhale/blob/main/CONTRIBUTING.md" },
64 },
65 {
66 n: "04",
67 title: "在 PR 中说明结果",
68 body: "说明问题、修改原因、已运行的检查和剩余风险;如果已有 issue,请在 PR 中关联。",
69 cta: { label: "查看 open pull requests", href: "https://github.com/codewhale-hq/CodeWhale/pulls" },
70 },
71 ];
72
73 const pathsEn = [
74 {
75 title: "Report a bug or compatibility problem",
76 body: "Include your system, Codewhale version, reproduction steps, expected behavior, and any logs you can share safely.",
77 label: "File an issue",
78 href: "https://github.com/codewhale-hq/CodeWhale/issues/new/choose",
79 },
80 {
81 title: "Improve code or tests",
82 body: "Choose a well-bounded problem, make the smallest useful patch, and add a regression test that proves the changed behavior.",
83 label: "Browse open issues",
84 href: "https://github.com/codewhale-hq/CodeWhale/issues",
85 },
86 {
87 title: "Improve documentation or translations",
88 body: "Correct inaccurate guidance, add a practical example, or help a complete language pack stay natural and aligned with the English keys.",
89 label: "Read the localization guide",
90 href: "https://github.com/codewhale-hq/CodeWhale/blob/main/docs/LOCALIZATION.md",
91 },
92 {
93 title: "Reproduce and review existing work",
94 body: "Verify an issue or pull request with your platform and provider, then share the exact checks and results.",
95 label: "Browse pull requests",
96 href: "https://github.com/codewhale-hq/CodeWhale/pulls",
97 },
98 ];
99
100 const pathsZh = [
101 {
102 title: "报告 bug 或兼容性问题",
103 body: "提供系统信息、Codewhale 版本、复现步骤、期望行为和可公开的日志。",
104 label: "提交 issue",
105 href: "https://github.com/codewhale-hq/CodeWhale/issues/new/choose",
106 },
107 {
108 title: "改进代码或测试",
109 body: "选择一个边界清楚的问题,提交最小补丁,并用回归测试证明修改后的行为。",
110 label: "查看待处理 issues",
111 href: "https://github.com/codewhale-hq/CodeWhale/issues",
112 },
113 {
114 title: "改进文档或翻译",
115 body: "修正不准确的说明、补充实际示例,或帮助完整语言包保持自然且与英文键一致。",
116 label: "阅读本地化指南",
117 href: "https://github.com/codewhale-hq/CodeWhale/blob/main/docs/LOCALIZATION.md",
118 },
119 {
120 title: "复现和审查现有工作",
121 body: "验证 issue 或 pull request 在你的平台和提供商上的行为,并分享准确的测试结果。",
122 label: "浏览 pull requests",
123 href: "https://github.com/codewhale-hq/CodeWhale/pulls",
124 },
125 ];
126
127 const reviewNotesEn = [
128 "Keep one problem per pull request so the change is easy to test, review, and credit.",
129 "Add tests for new behavior. For documentation fixes, verify commands, configuration names, and the current version against the repository.",
130 "Open an issue before changing authentication, credentials, sandbox policy, release plumbing, branding, or global prompts.",
131 "If a maintainer needs to adapt or harvest a patch, the original contributor remains credited in the commit, changelog, and contributor list.",
132 ];
133
134 const reviewNotesZh = [
135 "一个 PR 只解决一个问题,便于测试、审查和保留贡献者署名。",
136 "新增行为应有测试;修正文档时,请核对实际命令、配置名和当前版本。",
137 "修改认证、凭据、沙箱、发布流程、品牌或全局提示词前,请先提交 issue 并确认范围。",
138 "如果维护者需要整理或摘取补丁,原作者仍会在提交、CHANGELOG 和贡献者名单中获得署名。",
139 ];
140
141 export default async function ContributePage({ params }: { params: Promise<{ locale: string }> }) {
142 const { locale } = await params;
143 const t = getContribute(locale);
144 const textLocale = pickTextLocale(locale);
145 const merch = getMerchCopy(locale);
146 const steps = { en: stepsEn, zh: stepsZh }[textLocale];
147 const paths = { en: pathsEn, zh: pathsZh }[textLocale];
148 const reviewNotes = { en: reviewNotesEn, zh: reviewNotesZh }[textLocale];
149
150 return (
151 <>
152 <PageHeader
153 kicker={t.kicker}
154 title={t.title}
155 lede={t.lede}
156 pose="write"
157 actions={
158 <>
159 <Link href="https://github.com/codewhale-hq/CodeWhale/issues/new/choose" className="btn btn-primary btn-lg">
160 {t.fileIssue}
161 </Link>
162 <Link href="https://github.com/codewhale-hq/CodeWhale/pulls" className="btn btn-secondary btn-lg">
163 {t.browsePulls}
164 </Link>
165 <Link href="https://github.com/codewhale-hq/CodeWhale/blob/main/CONTRIBUTING.md" className="btn btn-ghost btn-lg">
166 {t.fullGuide}
167 <Icon name="external" className="icon" />
168 </Link>
169 </>
170 }
171 />
172
173 <div className="page-body">
174 <Section id="contribute-paths" title={t.pathsTitle}>
175 <div className="grid-2">
176 {paths.map((path) => (
177 <Link key={path.title} href={path.href} className="tile">
178 <h3>{path.title}</h3>
179 <p>{path.body}</p>
180 <span className="section-link">
181 {path.label}
182 <Icon name="arrow-right" className="icon icon-flip" />
183 </span>
184 </Link>
185 ))}
186 </div>
187 </Section>
188
189 <Section id="contribute-workflow" title={t.workflowTitle}>
190 <ol className="steps">
191 {steps.map((step, index) => (
192 <li key={step.n}>
193 <span className="gs-step-index" aria-hidden="true">{index + 1}</span>
194 <h3>{step.title}</h3>
195 <p>{step.body}</p>
196 <Link href={step.cta.href} className="section-link">
197 {step.cta.label}
198 <Icon name="arrow-right" className="icon icon-flip" />
199 </Link>
200 </li>
201 ))}
202 </ol>
203 </Section>
204
205 <Section
206 id="contribute-review"
207 title={t.reviewTitle}
208 scope={t.reviewScope}
209 >
210 <ul className="group-card" role="list">
211 {reviewNotes.map((note) => (
212 <li key={note} className="group-row check-row">
213 <Icon name="check" className="icon" />
214 <span>{note}</span>
215 </li>
216 ))}
217 </ul>
218 </Section>
219
220 <Section
221 id="contribute-dev"
222 title={t.devTitle}
223 scope={t.devScope}
224 >
225 <pre tabIndex={0} className="code-block">
226 {`git clone https://github.com/YOUR_USERNAME/CodeWhale.git
227 cd CodeWhale
228 git checkout -b fix/your-change
229
230 cargo build
231 cargo test -p <owning-crate> --locked
232 cargo fmt --all -- --check
233 cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
234 cargo test --workspace --all-features --locked`}
235 </pre>
236 </Section>
237 <Section id="contributor-merch" title={merch.title} scope={merch.lede}>
238 <Link href={`/${locale}/merch`} className="btn btn-secondary">{merch.cta}</Link>
239 </Section>
240 </div>
241 </>
242 );
243 }
244
244 lines Plain Text