bugfix: navbar active link matching

This commit is contained in:
2025-07-17 10:43:50 -04:00
parent 33dba5e8b5
commit 3b2fac133a

View File

@ -39,7 +39,9 @@ const currentPath = Astro.url.pathname;
} }
const isExternal = item.href?.startsWith("http"); const isExternal = item.href?.startsWith("http");
const isActive = !isExternal && item.href === currentPath; const normalize = (url) => url?.replace(/\/+$/, '') || '/';
const isActive = !isExternal && normalize(item.href) === normalize(currentPath);
const nextItem = navItems[index + 1]; const nextItem = navItems[index + 1];
const shouldShowThinBar = nextItem && !nextItem.blockSeparator; const shouldShowThinBar = nextItem && !nextItem.blockSeparator;