fix: change the conditions on which links in the header are marked as active

This commit is contained in:
Dorian Niemiec 2024-11-05 23:17:14 +01:00
parent 074ccb9422
commit 68f45963ee

View file

@ -35,7 +35,7 @@ function Header({ docLinks }) {
<Link
href={navLink.href}
target={navLink.target}
className={`inline-block self-center ${pathname == navLink.href ? "bg-accent" : ""} text-inherit px-2 py-1.5 mx-1 rounded-sm hover:bg-accent/60 transition-colors`}
className={`inline-block self-center ${pathname == navLink.href || (navLink.href != "/" && pathname.indexOf(navLink.href + "/") == 0) ? "bg-accent" : ""} text-inherit px-2 py-1.5 mx-1 rounded-sm hover:bg-accent/60 transition-colors`}
>
{navLink.label}
</Link>
@ -131,7 +131,7 @@ function Header({ docLinks }) {
<Link
href={navLink.href}
target={navLink.target}
className={`inline-block align-middle ${pathname == navLink.href ? "bg-accent" : ""} text-inherit px-2 py-1 h-8 mx-1 rounded-sm hover:bg-accent/60 transition-colors`}
className={`inline-block align-middle ${pathname == navLink.href || (navLink.href != "/" && pathname.indexOf(navLink.href + "/") == 0) ? "bg-accent" : ""} text-inherit px-2 py-1 h-8 mx-1 rounded-sm hover:bg-accent/60 transition-colors`}
>
{navLink.label}
</Link>