Skip to content

Commit 9cdf0d4

Browse files
Merge branch 'main' into dependabot/npm_and_yarn/tailwindcss-4.3.2
2 parents 3fb90ef + 3f0d159 commit 9cdf0d4

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

osmium/src/ui/layout/main-navigation.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@ interface MainNavigationProps {}
1818
function 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}

0 commit comments

Comments
 (0)