mirror of
https://github.com/zoriya/vike-react-native-web-bug.git
synced 2025-12-06 06:36:18 +00:00
initial commit
This commit is contained in:
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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user