Skip to content

feat(docs): mirror documentation folders in the sidebar - #53

Merged
kieronlanning merged 1 commit into
mainfrom
feat/docs-hierarchical-display
Nov 3, 2026
Merged

kieronlanning merged 1 commit into
mainfrom
feat/docs-hierarchical-display

Conversation

@kieronlanning

Copy link
Copy Markdown
Contributor

Why

ZodSharp's prerelease docs (on main) now live in topic folders, and ADR 0011 already made a folder a path segment of the published URL. The display did not follow: the docs sidebar was still one flat list of thirty links, a page said nothing about the section it belonged to, and the flat prerelease URLs published today were about to 404 because docs.redirects only emitted pairs for the default channel.

What

  • Sidebar mirrors the tree (src/lib/docs/sidebar.ts) - buildChannelItems() returns SidebarDocItem[] (SidebarSlugEntry | SidebarGroupEntry) and nests each slug's folders into Starlight groups. A folder appears where its first page appears and absorbs its later pages, so the sync's reading order (docs.order / _Sidebar.md) survives; nesting is recursive; a folder's index.md links the folder's own address instead of a non-existent /index/ slug.
  • Page names its section (PageTitle.astro) - a tracked-uppercase trail above the <h1>, absent at the docs root.
  • Styles (global.css) - a nested group label is reduced to a section label (Starlight styles every group label like a top-level heading, which made a folder read like a second project).
  • Old URLs keep working on every channel (redirects.ts) - each docsPageRedirects pair is emitted under every base the project publishes (/docs/<id>/ and /docs/<id>/prerelease/); the existing guards still decide which pairs are real.
  • Docs - ADR 0011 gained decision 4 (the display) and the per-channel redirect rule; AGENTS.md and the docs-aggregation-rules skill describe the nested sidebar, the section trail and per-channel forwarding.

A flat corpus is unchanged: no folder in any slug means no group and no section trail.

Result

Overview
[Concepts]        Core Concepts . Composition and Transforms
Fluent Schema API
[Schemas]         String Validation ... Compiled Validators and Caching
[Generator] [Serialization] [Hosting] [Quality] [Development]
ASP.NET Core Integration

Seven groups for ZodSharp's seven source folders. /docs/zodsharp/prerelease/string-validation/ is now a noindex meta refresh to schemas/string-validation/ (30 moved pages), while the live channel (tag v2.4.2, which predates the move) still renders flat with no redirect shadowing it.

Tests

  • unit: a flat corpus stays flat, group placement and order, deep nesting, a folder index page, label spelling and trail, per-channel redirects, single-channel redirect base.
  • dist: the built sidebar of every published channel contains a group-label per folder (and none when flat), nested links carry the hierarchical URL, and the section trail appears only on nested pages.

Validation

format:check, lint, typecheck (0 errors), bun test tests/unit (335 pass), check:assets, check:projects, build (276 pages, all internal links valid), discovery:validate, check:links, check:generated, test:dist (42 pass, 2 skipped for the promotion-only assertions) - all green, against a docs mirror regenerated by a live data:sync.

ZodSharp publishes its prerelease pages in topic folders, and ADR 0011 made a
folder a path segment of the published URL - but the sidebar still flattened the
list, so the hierarchy existed only in the address.

- buildChannelItems nests a channel's pages into Starlight groups, one per
  folder, placed where the folder's first page appears so the sync's reading
  order survives; a nested index.md links the folder's own address.
- Each aggregated page names its section above the title, in the same spelling.
- docsPageRedirects forwards a moved page from every base the project publishes,
  so the flat prerelease URLs published today do not 404 when the folders land.
- A flat corpus renders exactly as before: no group, no section trail.

Tests cover flat corpora, group placement and order, deep nesting, folder
indexes, label spelling, per-channel redirects and the built HTML.
@kieronlanning
kieronlanning enabled auto-merge (squash) November 3, 2026 23:53
@kieronlanning
kieronlanning merged commit bbfb5a3 into main Nov 3, 2026
1 check passed
@kieronlanning
kieronlanning deleted the feat/docs-hierarchical-display branch November 3, 2026 23:55
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.

1 participant