summaryrefslogtreecommitdiff
path: root/src/components/organisms/ActiveLink.astro
blob: 8c01f92ed867cd51b46060135c6554e80c331e15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
---
import type { HTMLAttributes } from "astro/types";

type Props = HTMLAttributes<"a">;

const { href, class: className, ...props } = Astro.props;
const pathname = Astro.url.pathname;
const isActive = href === pathname;
---

<a {href} class:list={[className, { current: isActive }]} {...props}>
  <slot />
</a>
<style>
  a.current {
    font-weight: bolder;
  }
</style>