/* eslint-disable react/display-name */ /* eslint-disable react/prop-types */ import clsx from 'clsx' import { useRouter } from 'next/router' import NextLink, { LinkProps as NextLinkProps } from 'next/link' import MuiLink, { LinkProps as MuiLinkProps } from '@material-ui/core/Link' import { forwardRef } from 'react' type NextComposedProps = Omit, 'href'> & NextLinkProps const NextComposed = forwardRef((props, ref) => { const { as, href, replace, scroll, passHref, shallow, prefetch, ...other } = props return ( ) }) interface LinkPropsBase { activeClassName?: string innerRef?: React.Ref naked?: boolean } export type LinkProps = LinkPropsBase & NextComposedProps & Omit // A styled version of the Next.js Link component: // https://nextjs.org/docs/#with-link function Link(props: LinkProps) { const { href, activeClassName = 'active', className: classNameProps, innerRef, naked, ...other } = props const router = useRouter() const pathname = typeof href === 'string' ? href : href.pathname const className = clsx(classNameProps, { [activeClassName]: router.pathname === pathname && activeClassName, }) if (naked) { return } return ( ) } export default forwardRef((props, ref) => ( ))