aboutsummaryrefslogtreecommitdiff
path: root/examples/with-content/src/components/HeaderLink.astro
blob: e8e2e103b4558a26d801fc01cdef1bab7774db04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {}

const { href, class: className, ...props } = Astro.props;

const { pathname } = Astro.url;
const isActive = href === pathname || href === pathname.replace(/\/$/, '');
---

<a href={href} class:list={[className, { active: isActive }]} {...props}>
	<slot />
</a>
<style>
	a {
		display: inline-block;
		text-decoration: none;
	}
	a.active {
		font-weight: bolder;
		text-decoration: underline;
	}
</style>