source: components/Link.tsx@ 40ac7a9

main
Last change on this file since 40ac7a9 was 8ee4553, checked in by Bati <no-reply@…>, 7 months ago

scaffold Vike app with Bati

  • Property mode set to 100644
File size: 417 bytes
Line 
1import { usePageContext } from "vike-react/usePageContext";
2
3export 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}
Note: See TracBrowser for help on using the repository browser.