import * as React from 'react'
import NextLink from 'next/link'
import {UrlObject} from 'url'

type Props = {
	href: UrlObject,
	as?: UrlObject,
	prefetch?: boolean,
	replace?: boolean,
	shallow?: boolean,
	component?: React.ElementType,
}

const Link: React.FC<Props> = ({
	href,
	as,
	prefetch,
	replace,
	shallow,
	component: Component = 'a',
	...etcProps
}) => {
	return (
		<NextLink
			href={href}
			as={as}
			passHref
			replace={replace}
			shallow={shallow}
			prefetch={prefetch}
		>
			<Component
				{...etcProps}
			/>
		</NextLink>
	)
}

export default Link
