fix(header.liquid): set header link active state properly

This commit is contained in:
Cory Dransfeldt 2025-06-16 06:08:44 -07:00
parent d13984f114
commit 0c64cdf570
No known key found for this signature in database
4 changed files with 15 additions and 6 deletions

View file

@ -1,4 +1,12 @@
const normalizeUrl = (url) =>
url.replace(/index\.php$|index\.html$/i, '').replace(/\.php$|\.html$/i, '') || '/';
export default {
isLinkActive: (category, page) =>
page.includes(category) && page.split('/').filter((a) => a !== '').length <= 1
isLinkActive: (category, page) => {
const normalized = normalizeUrl(page);
return (
normalized.includes(category) && normalized.split('/').filter((a) => a !== '').length <= 1
);
},
normalizeUrl
};