@@ -11,17 +11,18 @@ const { lang, hasTranslation = true, translationPath } = Astro.props;
1111const l = lang as Lang ;
1212const isZh = lang === ' zh-hans' ;
1313
14+ // 根据当前语言读取导航与公共文案,缺失时回退到中文。
1415function t(key : keyof typeof ui [' zh-hans' ]): string {
1516 return ((ui [l ] as typeof ui [' zh-hans' ])[key ] ?? ui [' zh-hans' ][key ]) as string ;
1617}
1718
18- const navItems: { key: keyof typeof ui [' zh-hans' ]; href: string ; n : string }[] = [
19- { key: ' nav.about' , href: ` /${lang }/about ` , n: ' 01 ' },
20- { key: ' nav.projects' , href: ` /${lang }/projects ` , n: ' 02 ' },
21- { key: ' nav.tools' , href: ` /${lang }/tools ` , n: ' 03 ' },
22- { key: ' nav.learn' , href: ` /${lang }/learn ` , n: ' 04 ' },
23- { key: ' nav.community' , href: ` /${lang }/community ` , n: ' 05 ' },
24- { key: ' nav.contribute' , href: ` /${lang }/contribute ` , n: ' 06 ' },
19+ const navItems: { key: keyof typeof ui [' zh-hans' ]; href: string }[] = [
20+ { key: ' nav.about' , href: ` /${lang }/about ` },
21+ { key: ' nav.projects' , href: ` /${lang }/projects ` },
22+ { key: ' nav.tools' , href: ` /${lang }/tools ` },
23+ { key: ' nav.learn' , href: ` /${lang }/learn ` },
24+ { key: ' nav.community' , href: ` /${lang }/community ` },
25+ { key: ' nav.contribute' , href: ` /${lang }/contribute ` },
2526];
2627
2728const currentPath = Astro .url .pathname ;
@@ -50,13 +51,12 @@ const alternatePath = translationPath
5051 </div >
5152 </a >
5253
53- <!-- Desktop nav (numbered) -->
54+ <!-- Desktop nav -->
5455 <div class =" hidden lg:flex items-center gap-0.5" >
55- { navItems .map (({ key , href , n }) => {
56+ { navItems .map (({ key , href }) => {
5657 const active = currentPath .startsWith (href );
5758 return (
58- <a href = { href } class = { ` relative group px-3 py-2 text-[13px] flex items-center gap-1.5 transition-colors ${active ? ' text-signal-yellow' : ' text-bone-dim hover:text-bone' } ` } >
59- <span class = { ` font-mono text-[9px] tracking-[0.2em] ${active ? ' text-signal-yellow' : ' text-bone-mute' } ` } >{ n } </span >
59+ <a href = { href } class = { ` relative group px-3 py-2 text-[13px] transition-colors ${active ? ' text-signal-yellow' : ' text-bone-dim hover:text-bone' } ` } >
6060 <span >{ t (key )} </span >
6161 { active && <span class = " absolute -bottom-px left-3 right-3 h-px bg-signal-yellow" ></span >}
6262 </a >
@@ -67,9 +67,6 @@ const alternatePath = translationPath
6767 <!-- Right -->
6868 <div class =" flex items-center gap-1 sm:gap-2" >
6969
70- <!-- Live clock -->
71- <span class =" hidden md:inline-block font-mono text-[11px] text-bone-mute tabular-nums tracking-wider mr-3" data-clock >—</span >
72-
7370 <!-- Search -->
7471 <a href ={ ` /${lang }/search ` } class =" p-2 text-bone-dim hover:text-bone transition-colors" aria-label ={ t (' nav.search' )} >
7572 <svg class =" w-[18px] h-[18px]" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" stroke-width =" 1.5" >
@@ -133,11 +130,10 @@ const alternatePath = translationPath
133130 <!-- Mobile menu -->
134131 <div id =" mobile-menu" class =" hidden lg:hidden border-t border-bone/[0.07] py-4" >
135132 <div class =" flex flex-col" >
136- { navItems .map (({ key , href , n }) => {
133+ { navItems .map (({ key , href }) => {
137134 const active = currentPath .startsWith (href );
138135 return (
139- <a href = { href } class = { ` py-3 flex items-center gap-3 text-base transition-colors ${active ? ' text-signal-yellow' : ' text-bone-dim hover:text-bone' } ` } >
140- <span class = " font-mono text-[10px] text-bone-mute w-6" >{ n } </span >
136+ <a href = { href } class = { ` py-3 text-base transition-colors ${active ? ' text-signal-yellow' : ' text-bone-dim hover:text-bone' } ` } >
141137 <span >{ t (key )} </span >
142138 </a >
143139 );
0 commit comments