gabriel / musehub public
docs.ts typescript
32 lines 1.0 KB
Raw
sha256:20b27796ed512236119feef48b4577a8fd9ded05a15267dd4e6da23604ad1f1a docs: update Suggested Ownership Split table to reflect ful… Sonnet 5 31 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 3 commits
sha256:20b27796ed512236119feef48b4577a8fd9ded05a15267dd4e6da23604ad1f1a docs: update Suggested Ownership Split table to reflect ful… Sonnet 5 31 days ago
sha256:8ea2f75226d5834770ccaddbaa6efda1cc337446fd481bb385de8bec4555ae79 docs: Section 9 CI pipeline — confirm job queue is idempote… Sonnet 5 31 days ago
sha256:80e1a60a39562f6e616aaafbb27487f03abbec7d8ffc6164302b7a0c0bfc63ee docs: check off Section 0 items verified in inventory doc, … Sonnet 5 31 days ago