kjelsrud.dev/src/components/HeaderLink.astro
Sindre Kjelsrud a2a1bf3a85
💄 update website design
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
2024-02-21 22:19:08 +01:00

21 lines
450 B
Text

---
import type { HTMLAttributes } from 'astro/types';
type Props = HTMLAttributes<'a'>;
const { href, class: className, ...props } = Astro.props;
const { pathname } = Astro.url;
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;
font-weight: bolder;
}
</style>