2023-07-19 21:31:30 +02:00
|
|
|
---
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
a.active {
|
|
|
|
font-weight: bolder;
|
2023-08-22 16:01:37 +02:00
|
|
|
border-bottom: 2px solid;
|
2023-07-19 21:31:30 +02:00
|
|
|
}
|
|
|
|
</style>
|