blame.ts
typescript
sha256:3c58668648c7323bb9f5c6881cfe6a3f14fc93fcb73b537d253732952a5bf8bf
chore: bump version to 0.2.0rc12
Sonnet 4.6
patch
8 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:35d76015db2541686c33edd44343ea2d9f751325b4a5556cc9c4c9c0f84edbbe
chore: bump version to 0.2.0rc12
Sonnet 4.6
patch
6 days ago