main
tsx 12 lines 417 Bytes
Raw
1 import { usePageContext } from "vike-react/usePageContext";
2
3 export function Link({ href, children }: { href: string; children: string }) {
4 const pageContext = usePageContext();
5 const { urlPathname } = pageContext;
6 const isActive = href === "/" ? urlPathname === href : urlPathname.startsWith(href);
7 return (
8 <a href={href} className={isActive ? "is-active" : undefined}>
9 {children}
10 </a>
11 );
12 }