-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
The current navigation requires 3 clicks to read a statute section:
- Browse → Title 18 (shows chapter list)
- Title 18 → Chapter 7 (shows section list)
- Chapter 7 → § 111 (shows content)
This makes it hard to get a holistic view of a title or quickly scan across chapters. Users wanting to read the entire code of a title must click into each chapter separately.
Proposal: Expandable Full-Title Table of Contents
Transform `/browse/title-{n}/` into an expandable, searchable TOC that shows the complete title structure:
```
Title 18 — Crimes and Criminal Procedure
1,399 sections across 126 chapters
[Search within Title 18...]
▸ Part I — Crimes (§§ 1-2725)
▾ Chapter 7 — Assault (9 sections)
§ 111 — Assaulting, resisting, or impeding... [⚡ changed in PL 117-159]
§ 112 — Protection of foreign officials...
§ 113 — Assaults within maritime and territorial jurisdiction
...
▸ Chapter 9 — Bankruptcy (4 sections)
▸ Chapter 10 — Biological Weapons (5 sections)
...
▸ Part II — Criminal Procedure (§§ 3001-3772)
...
```
Key features
- Three-level hierarchy: Part → Chapter → Section (matching official USC structure)
- Expand/collapse: Click chapter headings to show/hide section list
- Section links: Click section to go to `/statute/{slug}/` detail page
- Chapter links: Click chapter heading to go to `/browse/title-{n}/chapter-{n}/` (existing page)
- Change indicators: Show which sections changed in recent release points (from diff manifest)
- Status badges: Repealed/Reserved/Omitted/Transferred/Renumbered (inline, using frontmatter status field feat: Add 'status' frontmatter field to transformer output #90)
- In-title search: Filter sections by keyword within the TOC
- Section count per chapter: Show (N sections) badge
Information architecture impact
- `/browse/` — unchanged (title listing)
- `/browse/title-{n}/` — enhanced (full expandable TOC replaces simple chapter list)
- `/browse/title-{n}/chapter-{n}/` — kept (useful as direct chapter deep-link, also used by section page sidebar)
- `/statute/{slug}/` — unchanged (section detail)
The chapter page stays because:
- It's the target for chapter-level links from other sites
- Section page sidebar links to it
- Breadcrumbs reference it
- But it becomes optional — users can navigate Title→Section directly from the enhanced title page
Reference implementations
- Cornell LII (`law.cornell.edu/uscode/text/18`): Part → Chapter hierarchy with expandable sections
- OLRC (`uscode.house.gov`): JavaScript tree view with progressive expansion
- Both use expand/collapse; neither shows change tracking (our differentiator)
Technical approach
- Astro SSG: render full TOC at build time (all sections are available as content collection entries)
- Client-side: Svelte component for expand/collapse + search filter
- Change indicators: read from diff manifest at build time (which sections changed between recent tags)
- Performance: Only render section titles in TOC, not full content (avoids 60K section rendering)
Performance considerations
- Title 42 (largest) has ~7,500 sections across 163 chapters — TOC HTML is ~300KB
- Use `
Details
` elements for zero-JS progressive enhancement - Lazy-render expanded chapter sections for DOM performance
- Consider virtual scroll for very large titles
Files to modify
- `apps/web/src/pages/browse/[title].astro` — major rewrite to expandable TOC
- New: `apps/web/src/components/TitleToc.svelte` — interactive expand/collapse + search
- Possibly: `apps/web/src/pages/browse/[title].astro` needs access to all sections per title (currently only has chapters)
Depends on
- feat: Add 'status' frontmatter field to transformer output #90 (status frontmatter field) — merged ✅
- Epic: Historical US Code versions — import OLRC release points 2013-2026 #44 (historical import) — for change indicators