fix sidebar active on trailing /

This commit is contained in:
Philip Ahlqvist 2024-01-10 22:49:36 +01:00
parent fdef76835a
commit 67dc9aea69

View file

@ -15,6 +15,7 @@ const items = await getCollection(collection) || [];
const description = await markdown.parse(frontmatter.description); const description = await markdown.parse(frontmatter.description);
const isActive = (href: string)=>{ const isActive = (href: string)=>{
if (href[href.length - 1] === '/') href.split('').pop().join('');
return href === pathname || href === pathname.split('/').slice(0,2).join('/'); return href === pathname || href === pathname.split('/').slice(0,2).join('/');
} }