Skip to content

Make SubNavigation locale-aware for prefixed routes - #254

Merged
mathewjordan merged 1 commit into
nulib-ds:mainfrom
martimpassos:fix/subnavigation-locale-aware-rooting
Jul 20, 2026
Merged

Make SubNavigation locale-aware for prefixed routes#254
mathewjordan merged 1 commit into
nulib-ds:mainfrom
martimpassos:fix/subnavigation-locale-aware-rooting

Conversation

@martimpassos

Copy link
Copy Markdown
Contributor

SubNavigation built its sidebar tree by rooting at the first path segment of the current page (segments[0]). For locale-prefixed content (e.g. content/fr/...) that first segment is the locale, not the section, so the sidebar for a page like /fr/a-propos/guide was rooted at /fr and listed every page under that locale (including unrelated sections like /fr/chronologie) instead of just the current section.

  • Added isLocaleSegment / rootDepthForSegments / rootSegmentForSegments helpers (using the existing canonicalizeLocaleCode) that root at <locale>/<section> (depth 2) when the first segment is a configured locale, else <section> (depth 1).
  • Registered locale-prefixed <locale>/<section> nodes as navigation roots — previously only depth-1 nodes could ever become roots.
  • Updated buildNavigationForFile and getPageInfo to use the locale-aware root segment.
  • EXCLUDED_ROOTS (works/search) are now matched against the section name, so they stay excluded under a locale prefix (fr/works) too.

@mathewjordan
mathewjordan self-requested a review July 20, 2026 14:25
@mathewjordan
mathewjordan merged commit fca2295 into nulib-ds:main Jul 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants