Something went wrong. Try again.
My website, rebuilt yet again
Something went wrong. Try again.
441 B · 14 lines
Astro
at main
123456789101112131415---import type { HTMLAttributes } from 'astro/types';
type Props = HTMLAttributes<'a'>;
const { href, class: className, ...props } = Astro.props;const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, '');const subpath = pathname.match(/[^\/]+/g);const isActive = href === pathname || href === '/' + (subpath?.[0] || '');---
<a href={href} class:list={[className, { 'font-bold': isActive }]} {...props}> <slot /></a>