File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,18 +18,25 @@ interface MainNavigationProps {}
1818function ListItemLink ( props : { item : SidebarItemLink ; prefix ?: string } ) {
1919 const location = useLocation ( ) ;
2020 const locale = useLocale ( ) ;
21+ const href = ( ) =>
22+ locale . applyPathPrefix (
23+ `${ props . prefix === "/" ? "" : ( props . prefix ?? "" ) } ${ props . item . link === "/" ? "" : props . item . link } ` . replace (
24+ / \\ / g,
25+ "/"
26+ )
27+ ) ;
28+ const isActive = ( ) => location . pathname === href ( ) ;
2129
2230 const linkStyles = ( ) =>
23- location . pathname === props . item . link . replace ( / \\ / g , "/" )
31+ isActive ( )
2432 ? "font-semibold text-blue-700 before:bg-blue-700 dark:before:bg-blue-200 dark:text-blue-300 before:block"
2533 : "text-slate-700 before:hidden before:bg-blue-600 before:dark:bg-blue-200 hover:text-blue-700 hover:before:block dark:text-slate-300 " ;
2634 return (
2735 < li class = "relative" >
2836 < a
2937 onClick = { ( ) => setIsOpen ( false ) }
30- href = { locale . applyPathPrefix (
31- `${ props . prefix === "/" ? "" : ( props . prefix ?? "" ) } ${ props . item . link === "/" ? "" : props . item . link } `
32- ) }
38+ href = { href ( ) }
39+ aria-current = { isActive ( ) ? "page" : undefined }
3340 class = { `block w-full pl-3.5 before:pointer-events-none before:absolute before:top-1/2 before:-left-1 before:h-1.5 before:w-1.5 before:-translate-y-1/2 before:rounded-full hover:text-blue-700 lg:text-sm dark:hover:text-blue-300 ${ linkStyles ( ) } ` }
3441 >
3542 { props . item . title }
You can’t perform that action at this time.
0 commit comments