@@ -21,6 +21,16 @@ import Button from '../Button';
2121import SwitchToggle from './SwitchToggle' ;
2222
2323const inter = Inter ( { subsets : [ 'latin' ] } ) ;
24+ const normalizePath = ( path : string ) : string => path . replace ( / \/ + $ / , '' ) ;
25+ const isActivePath = (
26+ pathname : string | null ,
27+ lang : string ,
28+ path : string ,
29+ ) : boolean => {
30+ const target = normalizePath ( `/${ lang } ${ path } ` ) ;
31+ const current = normalizePath ( pathname ?? '' ) ;
32+ return current === target || current . startsWith ( `${ target } /` ) ;
33+ } ;
2434
2535export type NavLink = {
2636 name : string ;
@@ -46,13 +56,6 @@ function DesktopNavMenus(
4656 const router = useRouter ( ) ;
4757 const supabase = getSupabaseBrowserClient ( ) ;
4858
49- const normalizePath = ( path : string ) : string => path . replace ( / \/ + $ / , '' ) ;
50- const isActivePath = ( path : string ) : boolean => {
51- const target = normalizePath ( `/${ lang } ${ path } ` ) ;
52- const current = normalizePath ( pathname ?? '' ) ;
53- return current === target || current . startsWith ( `${ target } /` ) ;
54- } ;
55-
5659 return (
5760 < div
5861 className = { clsx ( 'flex-1 justify-between items-center' , 'max-md:hidden' ) }
@@ -71,7 +74,9 @@ function DesktopNavMenus(
7174 href = { `${ link . path } ` }
7275 className = { clsx (
7376 'text-body4 truncate' ,
74- isActivePath ( link . path ) ? 'opacity-100' : 'opacity-30' ,
77+ isActivePath ( pathname , lang , link . path )
78+ ? 'opacity-100'
79+ : 'opacity-30' ,
7580 ) }
7681 >
7782 < li
@@ -137,13 +142,6 @@ function MobileNavMenus(
137142
138143 const [ isNavCollapsed , setIsNavCollapsed ] = useState ( true ) ;
139144
140- const normalizePath = ( path : string ) : string => path . replace ( / \/ + $ / , '' ) ;
141- const isActivePath = ( path : string ) : boolean => {
142- const target = normalizePath ( `/${ lang } ${ path } ` ) ;
143- const current = normalizePath ( pathname ?? '' ) ;
144- return current === target || current . startsWith ( `${ target } /` ) ;
145- } ;
146-
147145 return (
148146 < div className = { clsx ( 'md:hidden flex-1' , 'flex flex-row-reverse' ) } >
149147 < div className = "cursor-pointer" >
@@ -183,7 +181,9 @@ function MobileNavMenus(
183181 'text-body4 truncate flex-1 h-10 px-8' ,
184182 'flex items-center' ,
185183 'hover:opacity-100' ,
186- isActivePath ( link . path ) ? 'opacity-100' : 'opacity-30' ,
184+ isActivePath ( pathname , lang , link . path )
185+ ? 'opacity-100'
186+ : 'opacity-30' ,
187187 ) }
188188 >
189189 < li
@@ -261,7 +261,7 @@ export default function Header(props: Props): ReactElement {
261261 path : `/stats/${ login } ` ,
262262 } ,
263263 {
264- name : t . recentList ,
264+ name : t . leaderboards ,
265265 path : '/leaderboards' ,
266266 } ,
267267 ]
@@ -271,7 +271,7 @@ export default function Header(props: Props): ReactElement {
271271 path : `/stats` ,
272272 } ,
273273 {
274- name : t . recentList ,
274+ name : t . leaderboards ,
275275 path : '/leaderboards' ,
276276 } ,
277277 ] ;
0 commit comments