From 3125cb04f7c608f17921a0aa7d91e1a32323acb4 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli-ai-agent <268630448+NullVoxPopuli-ai-agent@users.noreply.github.com> Date: Mon, 20 Jul 2026 12:57:38 -0400 Subject: [PATCH 1/4] docs-support: highlight the side-nav for extension-suffixed URLs Docs pages are reachable both extension-less (the nav's own hrefs) and with .md / .gjs.md suffixes (every prose cross-link produces these), and collection indexes at both /section and /section/index. The link helper's isActive compares URLs exactly, so following any cross-link silently dropped the nav highlight. Normalize both sides before comparing. Co-Authored-By: Claude Fable 5 --- packages/docs-support/src/side-nav.gts | 30 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/docs-support/src/side-nav.gts b/packages/docs-support/src/side-nav.gts index 27924285b..b4663ad19 100644 --- a/packages/docs-support/src/side-nav.gts +++ b/packages/docs-support/src/side-nav.gts @@ -3,7 +3,7 @@ import { on } from '@ember/modifier'; import { service } from '@ember/service'; import { sentenceCase } from 'change-case'; -import { link } from 'ember-primitives/helpers'; +import { link, service as getService } from 'ember-primitives/helpers'; import { PageNav } from 'kolay/components'; import { getAnchor } from 'should-handle-link'; @@ -70,14 +70,34 @@ const asComponent = (str: string) => { return `<${str.split('.')[0]?.replaceAll(' ', '')} />`; }; +/** + * Docs pages are reachable both with and without their file extension + * (prose cross-links produce `/2-usage/data.md`, while the nav's own + * hrefs are extension-less), and collection index pages are reachable + * at both `/2-usage` and `/2-usage/index`. Normalize both sides before + * comparing, so the nav highlight survives however the reader got to + * the page. + */ +function isActivePath(currentURL: string | null | undefined, href: string) { + if (!currentURL) return false; + + const normalize = (path: string) => + (path.split('?')[0] ?? '') + .replace(/\.gjs\.md$|\.gjs$|\.md$/, '') + .replace(/\/index$/, '') + .replace(/\/$/, ''); + + return normalize(currentURL) === normalize(href); +} + const isComponents = (str: string) => str === 'components'; const SectionLink: TOC<{ Element: HTMLAnchorElement; Args: { href: string; name: string } }> =