feat: refine global tokens, nav active state, section title

This commit is contained in:
William Valentin
2026-03-14 11:55:58 -07:00
parent ab7a83c50d
commit a6902e8d6c
2 changed files with 41 additions and 14 deletions
+12
View File
@@ -107,6 +107,7 @@
} else {
app.innerHTML = '<p>Page not found</p>';
}
updateActiveNav();
}
function navigate(path) {
@@ -114,6 +115,17 @@
route();
}
function updateActiveNav() {
const path = window.location.pathname;
document.querySelectorAll('header nav a').forEach(a => {
const href = a.getAttribute('href');
const isActive = href === '/'
? path === '/'
: path.startsWith(href);
a.classList.toggle('active', isActive);
});
}
window.addEventListener('popstate', route);
async function api(path) {