CoastalCommitsPastes/client/components/Link.tsx
2022-03-06 17:27:13 -08:00

11 lines
435 B
TypeScript

import { Link as GeistLink, LinkProps } from "@geist-ui/core"
import { useRouter } from "next/router";
const Link = (props: LinkProps) => {
const { basePath } = useRouter();
const propHrefWithoutLeadingSlash = props.href ? props.href.replace(/^\//, "") : props.href;
const href = basePath ? `/${basePath}/${propHrefWithoutLeadingSlash}` : props.href;
return <GeistLink {...props} href={href} />
}
export default Link