active link style
This commit is contained in:
14
packages/website/src/components/nav-link.astro
Normal file
14
packages/website/src/components/nav-link.astro
Normal 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>
|
||||
Reference in New Issue
Block a user