Initial commit
This commit is contained in:
commit
b344a74a72
45 changed files with 1232 additions and 0 deletions
13
components/Link.tsx
Normal file
13
components/Link.tsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React from "react";
|
||||
import { usePageContext } from "vike-react/usePageContext";
|
||||
|
||||
export function Link({ href, children }: { href: string; children: string }) {
|
||||
const pageContext = usePageContext();
|
||||
const { urlPathname } = pageContext;
|
||||
const isActive = href === "/" ? urlPathname === href : urlPathname.startsWith(href);
|
||||
return (
|
||||
<a href={href} className={isActive ? "is-active" : undefined}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue