Skip to content

Commit

Permalink
Another try
Browse files Browse the repository at this point in the history
  • Loading branch information
KubaZ2 committed Aug 30, 2024
1 parent 8d6f4c1 commit 328bc49
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Documentation/templates-src/NetCord/src/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ function inThisArticle(): TemplateResult {
function findActiveItem(items: (NavItem | NavItemContainer)[]): NavItem {
const url = new URL(window.location.href);
let activeItem: NavItem;
let maxPrefix = 1;
let maxPrefix = 0;
for (const item of items.map((i) => ("items" in i ? i.items : i)).flat()) {
if (isExternalHref(item.href)) {
continue;
}
const prefix = commonUrlPrefix(url, item.href);
if (prefix > maxPrefix) {
if (prefix == maxPrefix) {
activeItem = undefined;
}
else if (prefix > maxPrefix) {
maxPrefix = prefix;
activeItem = item;
}
Expand Down

0 comments on commit 328bc49

Please sign in to comment.