| 1 | "use client"; |
| 2 | |
| 3 | import Link from "next/link"; |
| 4 | import { usePathname } from "next/navigation"; |
| 5 | import { currentNavHref, type ChromeLink } from "@/lib/i18n/links"; |
| 6 | |
| 7 | /** |
| 8 | * Desktop primary navigation, shown from `lg`. Labels come from the locale's |
| 9 | * chrome dictionary — no locale branch here and no companion labels: at 2xl, |
| 10 | * de/pt-BR/id companions once collapsed the home wordmark to a zero-width |
| 11 | * hit target (#5290). |
| 12 | * |
| 13 | * Wrapping is the strip's escape valve for a translated strip that outgrows |
| 14 | * the row at the `lg` floor. The row gap is tight so a wrapped second row |
| 15 | * does not double the height of the sticky header. |
| 16 | */ |
| 17 | export function NavLinks({ |
| 18 | links, |
| 19 | primaryAria, |
| 20 | }: { |
| 21 | links: ChromeLink[]; |
| 22 | primaryAria: string; |
| 23 | }) { |
| 24 | const pathname = usePathname(); |
| 25 | // One link is the page; ancestors are not. See currentNavHref. |
| 26 | const current = currentNavHref(links, pathname); |
| 27 | |
| 28 | return ( |
| 29 | <nav className="hidden lg:flex min-w-0 shrink items-center gap-x-5 gap-y-1 flex-wrap" aria-label={primaryAria}> |
| 30 | {links.map((l) => { |
| 31 | const isActive = l.href === current; |
| 32 | return ( |
| 33 | <Link key={l.href} href={l.href} className="nav-link group inline-flex items-baseline" aria-current={isActive ? "page" : undefined}> |
| 34 | <span className="leading-none">{l.label}</span> |
| 35 | </Link> |
| 36 | ); |
| 37 | })} |
| 38 | </nav> |
| 39 | ); |
| 40 | } |
| 41 |