Merge pull request #22 from cassidoo/cw/headerlinks
Add check for header link and trailing slash
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
---
|
---
|
||||||
const { href, class: className, ...props } = Astro.props;
|
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}>
|
<a href={href} class:list={[className, { active: isActive }]} {...props}>
|
||||||
|
|||||||
Reference in New Issue
Block a user