astro-deploy/src/components/layout/HeaderLink.astro
2024-03-07 08:57:13 +01:00

14 lines
359 B
Plaintext

---
const { pathname } = Astro.url;
const { class: className = '', href, ...props } = Astro.props;
const isActive =
href === pathname || href === (pathname.endsWith('/') ? pathname.slice(0, -1) : pathname);
---
<a
href={href}
class={`inline-block ${className} ${isActive ? 'font-bold underline' : 'font-medium no-underline'}`}
{...props}>
<slot />
</a>