Something went wrong. Try again.
Source code for fatdragons.site fatdragons.site
Something went wrong. Try again.
551 B · 26 lines
Astro
at master
123456789101112131415161718192021222324252627---interface Props { href: string; lizard?: string; //question mark is for optional arguments}
let { href, lizard } = Astro.props;// (is the same as)// let href = Astro.props.href// let lizard = Astro.props.lizard
const linkUrl = new URL(href, Astro.url)// if href = "/posts"// then, linkUrl.toString() = "http://localhost/posts"
const isLinkActive = linkUrl.toString() === Astro.url.toString()---
<a href={href} class:list={{ active: isLinkActive }}><slot></slot></a>
<style> a.active { color: red; font-weight: bold; }</style>