diff --git a/static/app.css b/static/app.css index 44bf478..951cb13 100644 --- a/static/app.css +++ b/static/app.css @@ -187,6 +187,15 @@ nav a { } nav a:hover { color: var(--fg); border-bottom-color: transparent; } +nav a.active { + color: var(--fg); + border-bottom-color: var(--fg); +} +.offcanvas-links a.active { + color: var(--fg); + border-bottom-color: var(--fg); +} + footer { padding: 0.9rem 1.5rem; color: var(--muted); diff --git a/templates/page.html b/templates/page.html index e1780f3..6b8689c 100644 --- a/templates/page.html +++ b/templates/page.html @@ -24,9 +24,9 @@ ← FLÓ.FO FLÓ / ZEITKORT @@ -100,6 +100,20 @@ if (closeBtn) closeBtn.addEventListener('click', close); if (overlay) overlay.addEventListener('click', close); panel.querySelectorAll('a').forEach(function(a) { a.addEventListener('click', close); }); + + // Mark active link on click + document.querySelectorAll('nav a, .offcanvas-links a').forEach(function(a) { + a.addEventListener('click', function() { + document.querySelectorAll('nav a, .offcanvas-links a').forEach(function(el) { + el.classList.remove('active'); + }); + var href = a.getAttribute('hx-get') || a.getAttribute('href'); + document.querySelectorAll('nav a, .offcanvas-links a').forEach(function(el) { + var elHref = el.getAttribute('hx-get') || el.getAttribute('href'); + if (elHref === href) el.classList.add('active'); + }); + }); + }); })();