mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 16:56:34 +01:00
fix(website/i18n): header link not indicating active
This commit is contained in:
@@ -10,6 +10,7 @@ import logoPath from "../assets/icon-color.svg";
|
|||||||
import menuIcon from "../assets/boxicons/bx-menu.svg?raw";
|
import menuIcon from "../assets/boxicons/bx-menu.svg?raw";
|
||||||
import { LocaleContext } from "..";
|
import { LocaleContext } from "..";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { swapLocaleInUrl } from "../i18n";
|
||||||
|
|
||||||
interface HeaderLink {
|
interface HeaderLink {
|
||||||
url: string;
|
url: string;
|
||||||
@@ -53,16 +54,17 @@ export function Header(props: {repoStargazersCount: number}) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav className={`${mobileMenuShown ? "mobile-shown" : ""}`}>
|
<nav className={`${mobileMenuShown ? "mobile-shown" : ""}`}>
|
||||||
{headerLinks.map(link => (
|
{headerLinks.map(link => {
|
||||||
<Link
|
const linkHref = link.external ? link.url : swapLocaleInUrl(link.url, locale);
|
||||||
href={link.external ? link.url : `/${locale}${link.url}`}
|
return (<Link
|
||||||
className={url === link.url ? "active" : ""}
|
href={linkHref}
|
||||||
|
className={url === linkHref ? "active" : ""}
|
||||||
openExternally={link.external}
|
openExternally={link.external}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setMobileMenuShown(false);
|
setMobileMenuShown(false);
|
||||||
}}
|
}}
|
||||||
>{link.text}</Link>
|
>{link.text}</Link>)
|
||||||
))}
|
})}
|
||||||
|
|
||||||
<SocialButtons className="mobile-only" withText />
|
<SocialButtons className="mobile-only" withText />
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
Reference in New Issue
Block a user