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'); }); }