# S05: Frontend — Nested Rendering, TOC, Citations

**Goal:** Format-2 technique pages render with nested H2/H3 sections, a clickable Table of Contents, and citation markers that link to key moments. Format-1 pages render identically to before.
**Demo:** After this: Format-2 page renders with TOC, nested sections, clickable citations. Format-1 pages unchanged.

## Tasks
- [x] **T01: Added format-aware v2 body_sections rendering with nested TOC, citation anchor links, and subsection styles while preserving v1 dict rendering unchanged** — Update frontend TypeScript types to include body_sections_format and source_videos from S03. Build format-aware renderer in TechniquePage.tsx that detects v2 (list-of-objects) vs v1 (dict) body_sections and renders accordingly. V2 renderer: iterate BodySection[] → H2 with id slug + content paragraph + subsections (H3 + content). Per D024, sections with subsections have empty-string content — skip empty <p> tags. Create TableOfContents component that takes v2 sections and renders nested anchor list. Parse [N] and [N,M] citation markers in content strings and replace with <a> links to #km-{momentId}. Add all CSS (TOC styles, subsection styles, citation link superscript). Update snapshotToOverlay to pass through list-format body_sections.
  - Estimate: 2h
  - Files: frontend/src/api/public-client.ts, frontend/src/pages/TechniquePage.tsx, frontend/src/components/TableOfContents.tsx, frontend/src/utils/citations.tsx, frontend/src/App.css
  - Verify: cd frontend && npm run build
- [x] **T02: Deployed v2-aware frontend to ub01 and verified production site loads with HTTP 200, healthy API, and correct JS bundle hash** — Push changes to ub01, rebuild the web container, and verify that existing v1 technique pages render correctly with no regressions. Since no v2 pages exist in production yet (S04 hasn't populated any), v2 rendering is verified structurally via the TypeScript build. This task confirms the live deployment works.
  - Estimate: 30m
  - Files: frontend/src/pages/TechniquePage.tsx
  - Verify: ssh ub01 'cd /vmPool/r/repos/xpltdco/chrysopedia && git pull && docker compose build chrysopedia-web-8096 && docker compose up -d chrysopedia-web-8096' && sleep 5 && curl -s -o /dev/null -w '%{http_code}' http://ub01:8096/
