1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/components/Link.tsx
Mike Surowiec bc1ee6c60d Custom Link component (#19682)
* use our own Link component instead of next/link directly

* only show link href warnings outside of production environments
2021-06-03 08:21:33 -07:00

26 lines
590 B
TypeScript

import NextLink from 'next/link'
import { ComponentProps } from 'react'
const { NODE_ENV } = process.env
const enableNextLinks = false
type Props = { locale?: string } & ComponentProps<'a'>
export function Link(props: Props) {
const { href, locale, ...restProps } = props
if (!href && NODE_ENV !== 'production') {
console.warn('Missing href on Link')
}
if (enableNextLinks) {
return (
<NextLink href={href || ''} locale={locale}>
<a {...restProps} />
</NextLink>
)
}
return <a href={locale ? `/${locale}${href}` : href} {...restProps} />
}