docs.ts
typescript
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7
test(mwp3): Phase 4 — fix adjacent suite regressions, lock …
Sonnet 4.6
22 days ago
| 1 | /** |
| 2 | * docs.ts — scroll-spy sidebar for all Muse developer docs pages. |
| 3 | * |
| 4 | * Observes .devdocs-section[id] elements and marks the matching |
| 5 | * .devdocs-nav-link--sub link active as sections scroll into view. |
| 6 | * |
| 7 | * Registered for every docs-* page key in app.ts. |
| 8 | */ |
| 9 | |
| 10 | function initScrollSpy(): void { |
| 11 | const links = document.querySelectorAll<Element>('.devdocs-nav-link--sub'); |
| 12 | if (!links.length) return; |
| 13 | const observer = new IntersectionObserver( |
| 14 | (entries) => { |
| 15 | entries.forEach((e) => { |
| 16 | if (e.isIntersecting) { |
| 17 | links.forEach((l) => l.classList.remove('devdocs-nav-link--active')); |
| 18 | const target = document.querySelector( |
| 19 | `.devdocs-nav-link--sub[href="#${e.target.id}"]` |
| 20 | ); |
| 21 | if (target) target.classList.add('devdocs-nav-link--active'); |
| 22 | } |
| 23 | }); |
| 24 | }, |
| 25 | { rootMargin: '-20% 0px -70% 0px' } |
| 26 | ); |
| 27 | document.querySelectorAll('.devdocs-section[id]').forEach((s) => observer.observe(s)); |
| 28 | } |
| 29 | |
| 30 | export function initDocs(): void { |
| 31 | initScrollSpy(); |
| 32 | } |
File History
2 commits
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7
test(mwp3): Phase 4 — fix adjacent suite regressions, lock …
Sonnet 4.6
22 days ago
sha256:1749b9cc5cd2583c56d3261c4c00a342c27435f3946d4bc3e70f76aa2795458a
docs(mwp-3): TDD implementation plan for job-enqueue idempo…
Opus 4.8
22 days ago