aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/HeaderLink.astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/HeaderLink.astro')
-rw-r--r--src/components/HeaderLink.astro24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/HeaderLink.astro b/src/components/HeaderLink.astro
new file mode 100644
index 0000000..3dd439b
--- /dev/null
+++ b/src/components/HeaderLink.astro
@@ -0,0 +1,24 @@
+---
+import type { HTMLAttributes } from 'astro/types';
+
+type Props = HTMLAttributes<'a'>;
+
+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>
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage