返回 CodeWhale
nav-links.tsx
根目录 / web / components / nav-links.tsx
1 "use client";
2
3 import Link from "next/link";
4 import { usePathname } from "next/navigation";
5 import type { ChromeLink } from "@/lib/i18n/links";
6
7 /**
8 * Desktop primary navigation. Both the landmark label and the small
9 * bilingual companion label come from the locale's chrome dictionary — no
10 * locale branch here, and no Han characters leaking into locales that never
11 * asked for them.
12 */
13 export function NavLinks({
14 links,
15 primaryAria,
16 }: {
17 links: ChromeLink[];
18 primaryAria: string;
19 }) {
20 const pathname = usePathname();
21
22 return (
23 <nav className="hidden md:flex items-center gap-7" aria-label={primaryAria}>
24 {links.map((l) => {
25 const isActive = pathname === l.href || pathname.startsWith(`${l.href}/`);
26 return (
27 <Link key={l.href} href={l.href} className="nav-link group" aria-current={isActive ? "page" : undefined}>
28 <span>{l.label}</span>
29 {l.secondary && (
30 <span className="font-cjk text-[0.66rem] ml-1.5 text-ink-mute">{l.secondary}</span>
31 )}
32 </Link>
33 );
34 })}
35 </nav>
36 );
37 }
38
38 lines Plain Text