noway.moe/src/components/HeaderLink.astro

26 lines
473 B
Plaintext
Raw Normal View History

2023-12-25 20:01:37 -07: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(/\/$/, '');
---
2023-12-25 22:08:17 -07:00
<a href={href} class="hover:underline" {...props}>
2023-12-25 20:01:37 -07:00
<slot />
</a>
2023-12-25 22:08:17 -07:00
2023-12-25 20:01:37 -07:00
<style>
a {
display: inline-block;
text-decoration: none;
}
a.active {
font-weight: bolder;
text-decoration: underline;
}
</style>