gabriel / musehub public
docs.ts typescript
32 lines 1.0 KB
Raw
sha256:42bc547653458bb15e283222247af0237872d9cb5c2a72ad2ca1c111ed2c0ca4 feat(9A-4 F7): overseer-run provenance enrichment API for S… Human minor ⚠ breaking 15 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 1 commit
sha256:e5530c6b8996b96fc4030d6d30fe4f688926bdda2875fb01d303092b11513bd2 fix(9A-4 F7): env alias + staging secrets for overseer prov… Human minor 12 days ago