@@ -46,6 +46,13 @@ function DesktopNavMenus(
4646 const router = useRouter ( ) ;
4747 const supabase = getSupabaseBrowserClient ( ) ;
4848
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+
4956 return (
5057 < div
5158 className = { clsx ( 'flex-1 justify-between items-center' , 'max-md:hidden' ) }
@@ -64,7 +71,7 @@ function DesktopNavMenus(
6471 href = { `${ link . path } ` }
6572 className = { clsx (
6673 'text-body4 truncate' ,
67- pathname ?. includes ( link . path ) ? 'opacity-100' : 'opacity-30' ,
74+ isActivePath ( link . path ) ? 'opacity-100' : 'opacity-30' ,
6875 ) }
6976 >
7077 < li
@@ -130,6 +137,13 @@ function MobileNavMenus(
130137
131138 const [ isNavCollapsed , setIsNavCollapsed ] = useState ( true ) ;
132139
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+
133147 return (
134148 < div className = { clsx ( 'md:hidden flex-1' , 'flex flex-row-reverse' ) } >
135149 < div className = "cursor-pointer" >
@@ -169,7 +183,7 @@ function MobileNavMenus(
169183 'text-body4 truncate flex-1 h-10 px-8' ,
170184 'flex items-center' ,
171185 'hover:opacity-100' ,
172- pathname ?. includes ( link . path ) ? 'opacity-100' : 'opacity-30' ,
186+ isActivePath ( link . path ) ? 'opacity-100' : 'opacity-30' ,
173187 ) }
174188 >
175189 < li
@@ -248,17 +262,17 @@ export default function Header(props: Props): ReactElement {
248262 } ,
249263 {
250264 name : t . recentList ,
251- path : '/recent-list ' ,
265+ path : '/leaderboard ' ,
252266 } ,
253267 ]
254268 : [
255269 {
256270 name : t . stats ,
257- path : `/stats/ ` ,
271+ path : `/stats` ,
258272 } ,
259273 {
260274 name : t . recentList ,
261- path : '/recent-list ' ,
275+ path : '/leaderboard ' ,
262276 } ,
263277 ] ;
264278
0 commit comments