import React from "react"; import { usePageContext } from "./context"; import { Slot } from "@radix-ui/react-slot"; type LinkProps = { href?: string; className?: string; asChild?: boolean; children?: React.ReactNode; }; const Link = React.forwardRef( ({ asChild, href, ...props }, ref) => { const pageContext = usePageContext(); const { urlPathname } = pageContext; const Comp = asChild ? Slot : "a"; const isActive = href === "/" ? urlPathname === href : urlPathname.startsWith(href!); return ( ); } ); export default Link;