astro-deploy/src/components/layout/HeaderLink.astro
2024-03-06 11:27:09 +01:00

21 lines
408 B
Plaintext

---
const { pathname } = Astro.url;
const { class: className, href, ...props } = Astro.props;
const isActive = href === pathname || href === pathname.replace(/\/$/, '');
---
<a href={href} class:list={[className, { active: isActive }]} {...props}>
<slot />
</a>
<style>
a {
display: inline-block;
text-decoration: none;
}
a.active {
font-weight: bolder;
text-decoration: underline;
}
</style>