diff --git a/Documentation/templates-src/NetCord/partials/root.tmpl.partial b/Documentation/templates-src/NetCord/partials/root.tmpl.partial index 15f3b1773..44223a5e1 100644 --- a/Documentation/templates-src/NetCord/partials/root.tmpl.partial +++ b/Documentation/templates-src/NetCord/partials/root.tmpl.partial @@ -2,8 +2,8 @@
The modern and fully customizable C# Discord library
\ No newline at end of file diff --git a/Documentation/templates-src/NetCord/src/nav.ts b/Documentation/templates-src/NetCord/src/nav.ts index bb6379a6b..678f030fc 100644 --- a/Documentation/templates-src/NetCord/src/nav.ts +++ b/Documentation/templates-src/NetCord/src/nav.ts @@ -188,31 +188,19 @@ function inThisArticle(): TemplateResult { function findActiveItem(items: (NavItem | NavItemContainer)[]): NavItem { const url = new URL(window.location.href); - let activeItem: NavItem; - let maxPrefix = 1; 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) { - maxPrefix = prefix; - activeItem = item; - } + const href = item.href; + if (!isExternalHref(href) && commonUrl(url, href)) + return item; } - return activeItem; } -function commonUrlPrefix(url: URL, base: URL): number { - const urlSegments = url.pathname.split("/"); - const baseSegments = base.pathname.split("/"); - let i = 1; - while ( - i < urlSegments.length && - i < baseSegments.length && - urlSegments[i] === baseSegments[i] - ) { - i++; - } - return i; +function commonUrl(url: URL, base: URL): boolean { + const urlPath = normalizePath(url.pathname); + const basePath = normalizePath(base.pathname); + return urlPath === basePath; +} + +function normalizePath(url: string): string { + return url.replace(/\/(?:index.html)?$/, "/"); }