返回 CodeWhale
footer.tsx
根目录 / web / components / footer.tsx
1 import Link from "next/link";
2 import type { Locale } from "@/lib/i18n/config";
3 import { getChrome } from "@/lib/i18n/dictionaries";
4 import {
5 footerDocsLinks,
6 footerLegalLinks,
7 footerProductLinks,
8 footerProjectLinks,
9 type ChromeLink,
10 } from "@/lib/i18n/links";
11 import { SITE_CONTACT_EMAIL } from "@/lib/page-meta";
12 import { reviewState } from "@/lib/i18n/review-state";
13 import { USAGE_COUNTING_COPY } from "@/lib/content/usage-counting";
14 import { pickText } from "@/lib/i18n/dictionaries";
15
16 function FooterList({ links }: { links: ChromeLink[] }) {
17 return (
18 <div className="site-footer-list">
19 {links.map((item) => <Link key={item.href} href={item.href}>{item.label}</Link>)}
20 </div>
21 );
22 }
23
24 /**
25 * Site footer: the page's own ground under one hairline, in both
26 * appearances. One dictionary path for every routed locale; four short link
27 * columns (Product, Docs, Project, Legal), which fold into four disclosures
28 * on a phone.
29 */
30 export function Footer({ locale = "en" }: { locale?: Locale }) {
31 const chrome = getChrome(locale);
32 const homeHref = `/${locale}`;
33 const groups: { label: string; links: ChromeLink[] }[] = [
34 { label: chrome.footerProduct, links: footerProductLinks(locale, chrome) },
35 { label: chrome.footerDocs, links: footerDocsLinks(locale, chrome) },
36 { label: chrome.footerProject, links: footerProjectLinks(locale, chrome) },
37 { label: chrome.footerLegal, links: footerLegalLinks(locale, chrome, pickText(USAGE_COUNTING_COPY.footerLink, locale)) },
38 ];
39
40 return (
41 <footer className="site-footer">
42 <div className="site-footer-main">
43 <div className="site-footer-brand">
44 <Link href={homeHref} className="site-wordmark site-wordmark-footer" aria-label="Codewhale">
45 <span className="brand-mark" aria-hidden="true" />
46 <span className="wordmark" aria-hidden="true" />
47 </Link>
48 </div>
49
50 <div className="site-footer-links">
51 {groups.map((group) => (
52 <div key={group.label} className="site-footer-group">
53 <span className="site-footer-label">{group.label}</span>
54 <FooterList links={group.links} />
55 </div>
56 ))}
57 </div>
58 <div className="site-footer-folds">
59 {groups.map((group) => (
60 <details key={group.label} className="site-footer-fold" name="site-footer">
61 <summary>{group.label}</summary>
62 <FooterList links={group.links} />
63 </details>
64 ))}
65 </div>
66 </div>
67
68 <div className="site-footer-meta">
69 <a href={`mailto:${SITE_CONTACT_EMAIL}`}>{SITE_CONTACT_EMAIL}</a>
70 <span>© {new Date().getFullYear()} Codewhale</span>
71 {reviewState(locale) === "machine" && <span className="site-footer-review">{chrome.translationMachineDraft}</span>}
72 </div>
73 </footer>
74 );
75 }
76
76 lines Plain Text