2022-03-21 20:30:45 -07:00
|
|
|
import type { LinkProps } from "@geist-ui/core"
|
2022-03-22 20:06:15 -07:00
|
|
|
import { Link as GeistLink } from "@geist-ui/core"
|
2022-04-09 17:48:19 -07:00
|
|
|
import { useRouter } from "next/router"
|
2022-03-06 17:20:01 -08:00
|
|
|
|
|
|
|
const Link = (props: LinkProps) => {
|
2022-04-09 17:48:19 -07:00
|
|
|
const { basePath } = useRouter()
|
|
|
|
const propHrefWithoutLeadingSlash =
|
|
|
|
props.href && props.href.startsWith("/")
|
|
|
|
? props.href.substring(1)
|
|
|
|
: props.href
|
|
|
|
const href = basePath
|
|
|
|
? `${basePath}/${propHrefWithoutLeadingSlash}`
|
|
|
|
: props.href
|
|
|
|
return <GeistLink {...props} href={href} />
|
2022-03-06 17:20:01 -08:00
|
|
|
}
|
|
|
|
|
2022-03-06 17:27:13 -08:00
|
|
|
export default Link
|