Files
TheGame/packages/web/components/Link.tsx
2021-07-31 23:14:21 -04:00

45 lines
823 B
TypeScript

import { Link } from '@metafam/ds';
import NextLink, { LinkProps } from 'next/link';
import React from 'react';
type Props = Omit<React.ComponentProps<typeof Link>, keyof LinkProps> &
LinkProps;
export const MetaLink: React.FC<Props> = ({
children,
href,
as,
passHref,
replace,
scroll = true,
shallow,
isExternal,
...props
}) => {
if (isExternal && typeof href === 'string') {
return (
<Link color="cyan.400" isExternal href={href} {...props}>
{children}
</Link>
);
}
return (
<NextLink
{...{
href,
as,
replace,
scroll,
shallow,
}}
passHref={passHref || true}
>
{/* NextLink passes the href */}
<Link color="cyan.400" {...props}>
{children}
</Link>
</NextLink>
);
};