Fix basePath?

This commit is contained in:
Max Leiter 2022-03-06 17:27:13 -08:00
parent 144574535a
commit 9a0b83c992
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A3512F2F2F17EBDA

View file

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