summaryrefslogtreecommitdiff
path: root/src/components/organisms/ActiveLink.astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/organisms/ActiveLink.astro')
-rw-r--r--src/components/organisms/ActiveLink.astro18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/components/organisms/ActiveLink.astro b/src/components/organisms/ActiveLink.astro
new file mode 100644
index 0000000..8c01f92
--- /dev/null
+++ b/src/components/organisms/ActiveLink.astro
@@ -0,0 +1,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>