From e8226b2e2f47bdf0f564b33849c2fd7600a90d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Mon, 18 May 2026 17:33:42 +0200 Subject: [PATCH] Fix tab highlight: exact category URL match instead of substring /categories/dark-fantasy/ was also activating the Fantasy tab because path.includes('fantasy') matched. Now compares the full /categories/{slug}/ path. Co-Authored-By: Claude Sonnet 4.6 --- assets/js/app.js | 5 +++-- static/js/app.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 8c3c529..c7e1c97 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -91,8 +91,9 @@ const path = location.pathname; tabs.forEach(btn => { const cat = btn.dataset.cat; - const active = (cat === 'All' && (path === '/' || path.startsWith('/issue') || path === '/posts/')) - || (cat !== 'All' && path.toLowerCase().includes(cat.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''))); + const slug = cat.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''); + const active = (cat === 'All' && (path === '/' || path.startsWith('/issues') || path === '/posts/')) + || (cat !== 'All' && path === `/categories/${slug}/`); btn.setAttribute('aria-pressed', active ? 'true' : 'false'); }); } diff --git a/static/js/app.js b/static/js/app.js index 8c3c529..c7e1c97 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -91,8 +91,9 @@ const path = location.pathname; tabs.forEach(btn => { const cat = btn.dataset.cat; - const active = (cat === 'All' && (path === '/' || path.startsWith('/issue') || path === '/posts/')) - || (cat !== 'All' && path.toLowerCase().includes(cat.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''))); + const slug = cat.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''); + const active = (cat === 'All' && (path === '/' || path.startsWith('/issues') || path === '/posts/')) + || (cat !== 'All' && path === `/categories/${slug}/`); btn.setAttribute('aria-pressed', active ? 'true' : 'false'); }); }