active link style

This commit is contained in:
itsMapleLeaf
2023-03-12 16:14:46 -05:00
parent 6da6008d2c
commit 84348d287f
5 changed files with 46 additions and 32 deletions

View File

@@ -0,0 +1,14 @@
---
export type Props = astroHTML.JSX.AnchorHTMLAttributes & {
href: string
}
const url = Astro.url
const linkUrl = new URL(Astro.props.href, url)
---
<a
{...Astro.props}
data-active={url.pathname === linkUrl.pathname ? true : undefined}
>
<slot />
</a>