My website, rebuilt yet again
1---
2import type { HTMLAttributes } from 'astro/types';
3
4type Props = HTMLAttributes<'a'>;
5
6const { href, class: className, ...props } = Astro.props;
7const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, '');
8const subpath = pathname.match(/[^\/]+/g);
9const isActive = href === pathname || href === '/' + (subpath?.[0] || '');
10---
11
12<a href={href} class:list={[className, { 'font-bold': isActive }]} {...props}>
13 <slot />
14</a>