On production every page with navSection() headings renders an empty nav.chapters. The Navigation System feature page itself has no sidebar. The attachments do run and call addItem(), but nothing downstream reacts.

Cause

src/lib/Nav/Nav.svelte declares const itemsByPath = $state(new Map()). Svelte 5 only proxies plain objects and arrays; Map.set(), has() and get() are invisible to the reactivity graph, so let items = $derived(getItems(page.url.pathname)) is computed once with an empty array and never re-runs.

Tasks

  • Replace $state(new Map()) with new SvelteMap() from svelte/reactivity
  • Make the per-path item arrays reactive too (push/splice on a plain array inside a SvelteMap is fine, but verify with the derived)
  • Add a component test that mounts a page with two navSection() headings and asserts two links in the sidebar
  • Check the sidebar highlight on scroll still works after the change

Bring the sidebar back

One reactive Map away from a working Navigation System

A static site template built with SvelteKit.

Sveleton, 2025