| 1 | /** |
| 2 | * Locale-aware chrome link sets (#4934). |
| 3 | * |
| 4 | * Nav and footer used to carry hardcoded `/en/...` and `/zh/...` arrays plus |
| 5 | * a thin dictionary branch for everything else, so foreign locales silently |
| 6 | * lost the Start and FAQ links. There is now one generator per link set: |
| 7 | * labels come from `ChromeDict`, hrefs come from the locale, and every |
| 8 | * routed locale gets the identical route shape. Locale-swap parity is a |
| 9 | * unit test (`docs-ia.test.ts`) instead of a string scrape over the TSX. |
| 10 | */ |
| 11 | import type { ChromeDict } from "./dictionaries/types"; |
| 12 | |
| 13 | export const REPO_URL = "https://github.com/Hmbown/CodeWhale"; |
| 14 | export const REPO_ISSUES_URL = `${REPO_URL}/issues`; |
| 15 | export const REPO_RELEASES_URL = `${REPO_URL}/releases`; |
| 16 | export const REPO_LICENSE_URL = `${REPO_URL}/blob/main/LICENSE`; |
| 17 | /** Community chat. A brand name, so it is not a dictionary string. */ |
| 18 | export const DISCORD_URL = "https://discord.gg/37gfS3ksug"; |
| 19 | |
| 20 | /** A chrome link. `secondary` is the small bilingual companion label. */ |
| 21 | export interface ChromeLink { |
| 22 | href: string; |
| 23 | label: string; |
| 24 | secondary?: string; |
| 25 | } |
| 26 | |
| 27 | /** The six primary nav links, identical in shape for every routed locale. */ |
| 28 | export function navLinks(locale: string, chrome: ChromeDict): ChromeLink[] { |
| 29 | return [ |
| 30 | { href: `/${locale}/docs`, label: chrome.navDocs, secondary: chrome.navDocsSecondary }, |
| 31 | { |
| 32 | href: `/${locale}/docs/guide`, |
| 33 | label: chrome.navStart, |
| 34 | secondary: chrome.navStartSecondary, |
| 35 | }, |
| 36 | { |
| 37 | href: `/${locale}/install`, |
| 38 | label: chrome.navInstall, |
| 39 | secondary: chrome.navInstallSecondary, |
| 40 | }, |
| 41 | { href: `/${locale}/faq`, label: chrome.navFaq, secondary: chrome.navFaqSecondary }, |
| 42 | { |
| 43 | href: `/${locale}/community`, |
| 44 | label: chrome.navCommunity, |
| 45 | secondary: chrome.navCommunitySecondary, |
| 46 | }, |
| 47 | { |
| 48 | href: `/${locale}/contribute`, |
| 49 | label: chrome.navContribute, |
| 50 | secondary: chrome.navContributeSecondary, |
| 51 | }, |
| 52 | ]; |
| 53 | } |
| 54 | |
| 55 | /** Footer "Product" column — the in-site discovery links. */ |
| 56 | export function footerProductLinks(locale: string, chrome: ChromeDict): ChromeLink[] { |
| 57 | return [ |
| 58 | { href: `/${locale}/docs`, label: chrome.footerDocs }, |
| 59 | { href: `/${locale}/docs/guide`, label: chrome.footerGuide }, |
| 60 | { href: `/${locale}/install`, label: chrome.footerInstall }, |
| 61 | { href: `/${locale}/models`, label: chrome.footerModels }, |
| 62 | { href: `/${locale}/runtime`, label: chrome.footerRuntime }, |
| 63 | { href: `/${locale}/faq`, label: chrome.footerFaq }, |
| 64 | ]; |
| 65 | } |
| 66 | |
| 67 | /** Footer "Project" column — GitHub plus the pinned legal link. */ |
| 68 | export function footerProjectLinks(locale: string, chrome: ChromeDict): ChromeLink[] { |
| 69 | return [ |
| 70 | { href: REPO_URL, label: "GitHub" }, |
| 71 | { href: REPO_ISSUES_URL, label: chrome.footerIssues }, |
| 72 | { href: DISCORD_URL, label: "Discord" }, |
| 73 | { href: `/${locale}/contribute`, label: chrome.footerContribute }, |
| 74 | { href: REPO_LICENSE_URL, label: chrome.footerLicense }, |
| 75 | ]; |
| 76 | } |
| 77 |