Skip to content

Commit

Permalink
fix: Fixed invalid navbar link bug and invalid null redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-Klatzer committed Sep 16, 2024
1 parent 54a0fac commit f30dc56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/partials/header-nav-bar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const pages = {
// Insert locale name into the URL
const href = link.getAttribute("href");
if (!href.includes(localeName) && !href.includes("docs")) {
link.setAttribute("href", `/${localeName}${href}`);
link.setAttribute("href", `/${localeName}${window.location.pathname}`);
}
}
})();
Expand Down
2 changes: 1 addition & 1 deletion src/partials/meta-head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ See main.scss for the --scheme-primary variable
// In case a site was loaded with a different locale than the one in the locale storage, then we redirect to
// the correct locale
if (
storedLocale !== undefined &&
!!storedLocale &&
storedLocale !== locale.name &&
!window.location.pathname.includes(`/${storedLocale}/`) &&
!window.location.pathname.includes("/docs/")
Expand Down
14 changes: 14 additions & 0 deletions src/partials/phone-header-nav-bar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
</a>
</li>
<% } %>

<script defer>
(() => {
const links = document.querySelectorAll("#phone-header-nav-bar-menu li .top-nav-menu-item");
const localeName = localStorage.getItem(window.localeKey);
for (const link of links) {
// Insert locale name into the URL
const href = link.getAttribute("href");
if (!href.includes(localeName) && !href.includes("docs")) {
link.setAttribute("href", `/${localeName}${window.location.pathname}`);
}
}
})();
</script>
</ul>
</li>
<li>
Expand Down

0 comments on commit f30dc56

Please sign in to comment.