mirror of https://github.com/MaxLeiter/Drift
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
491 B
TypeScript
18 lines
491 B
TypeScript
import type { LinkProps } from "@geist-ui/core"
|
|
import { Link as GeistLink } from "@geist-ui/core"
|
|
import { useRouter } from "next/router"
|
|
|
|
const Link = (props: LinkProps) => {
|
|
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} />
|
|
}
|
|
|
|
export default Link
|