Add check for header link and trailing slash
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
---
|
||||
const { href, class: className, ...props } = Astro.props;
|
||||
let isActive = href === Astro.url.pathname;
|
||||
let isActive;
|
||||
|
||||
if (href === "/") {
|
||||
isActive = Astro.url.pathname === href;
|
||||
} else {
|
||||
isActive = Astro.url.pathname.startsWith(href);
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<a href={href} class:list={[className, { active: isActive }]} {...props}>
|
||||
|
||||
Reference in New Issue
Block a user