2022-03-21 23:30:45 -04:00
|
|
|
import type { LinkProps } from "@geist-ui/core"
|
|
|
|
import GeistLink from "@geist-ui/core/dist/link"
|
2022-03-06 20:20:01 -05:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
|
|
|
const Link = (props: LinkProps) => {
|
|
|
|
const { basePath } = useRouter();
|
2022-03-11 21:48:40 -05:00
|
|
|
const propHrefWithoutLeadingSlash = props.href && props.href.startsWith("/") ? props.href.substring(1) : props.href;
|
2022-03-06 20:29:34 -05:00
|
|
|
const href = basePath ? `${basePath}/${propHrefWithoutLeadingSlash}` : props.href;
|
2022-03-06 20:25:23 -05:00
|
|
|
return <GeistLink {...props} href={href} />
|
2022-03-06 20:20:01 -05:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:27:13 -05:00
|
|
|
export default Link
|