gabriel / musehub public
blame.ts typescript
24 lines 851 B
Raw
sha256:0521dce9aca20da6ab4d9ebee6de75ab876bd82cddbc6bd4897d1ac6ecd11d3d docs(musehub#129): freeze Phase 1 OG repo card design Human 15 days ago
1 /**
2 * blame.ts — interactivity for the code blame page.
3 *
4 * Registered as: window.MusePages['blame']
5 */
6
7 export function initBlame(_data: Record<string, unknown>): void {
8 // Line hash navigation: highlight target line on load and hash change
9 function highlightTargetLine(): void {
10 document.querySelectorAll<HTMLElement>('.blm-code-row--targeted').forEach((el) => {
11 el.classList.remove('blm-code-row--targeted');
12 });
13 const hash = window.location.hash;
14 if (!hash) return;
15 const target = document.querySelector<HTMLElement>(hash);
16 if (target && target.classList.contains('blm-code-row')) {
17 target.classList.add('blm-code-row--targeted');
18 target.scrollIntoView({ behavior: 'smooth', block: 'center' });
19 }
20 }
21
22 highlightTargetLine();
23 window.addEventListener('hashchange', highlightTargetLine);
24 }
File History 1 commit
sha256:6ad6d62107bbd6940c52d63327966b8a65c6391f4a3da6cd9e7548ba4b38bc48 feat(musehub#129): OG repo preview cards — endpoint, cache,… Human minor 15 days ago