mirror of
https://github.com/MeshEnvy/mesh-forge.git
synced 2026-03-28 17:42:55 +01:00
14 lines
454 B
TypeScript
14 lines
454 B
TypeScript
import type { ReactNode } from "react"
|
|
import { usePageContext } from "vike-react/usePageContext"
|
|
|
|
export function Link({ href, children }: { href: string; children: ReactNode }) {
|
|
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>
|
|
)
|
|
}
|