---
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 class:list={[className, { 'underline underline-offset-2 decoration-1': isActive }]} href={href} {...props}>
    <slot />
</a>
