diff options
| author | houston[bot] <astrobot-houston@users.noreply.github.com> | 2023-07-22 12:57:20 -0700 |
|---|---|---|
| committer | Pinapelz <donaldshan1@outlook.com> | 2023-07-22 12:57:20 -0700 |
| commit | 338bcf12e0b7bbd6e587ec992e62860642856e80 (patch) | |
| tree | 280c106666221697a40c13603a91ee4c696e0bfb /src/components/HeaderLink.astro | |
Initial commit from Astro
Diffstat (limited to 'src/components/HeaderLink.astro')
| -rw-r--r-- | src/components/HeaderLink.astro | 24 |
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> |
