Extract navbar and footer into shared header.html and footer.html partials

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 16:26:59 -05:00
co-authored by Claude Sonnet 4.6
parent 23c34c7f88
commit dbad722b95
7 changed files with 70 additions and 180 deletions
+20
View File
@@ -1 +1,21 @@
function loadHTML(file, elementId) {
fetch(file)
.then(r => r.text())
.then(html => {
document.getElementById(elementId).innerHTML = html;
if (elementId === 'header') highlightActiveNav();
})
.catch(err => console.error('Error loading:', file, err));
}
function highlightActiveNav() {
const current = location.pathname.split('/').pop() || 'index.html';
document.querySelectorAll('#header a[href]').forEach(link => {
if (link.getAttribute('href') === `/${current}`) {
link.classList.add('active');
}
});
}
loadHTML('/header.html', 'header');
loadHTML('/footer.html', 'footer');