22 lines
497 B
TypeScript
22 lines
497 B
TypeScript
import Link from 'next/link'
|
|
import { type ComponentProps, type PropsWithChildren } from 'react'
|
|
|
|
export type Props = ComponentProps<typeof Link>
|
|
|
|
const HybridLink = ({ href, children, ...rest }: PropsWithChildren<Props>) => {
|
|
if (href && (typeof href !== 'string' || href.startsWith('/')))
|
|
return (
|
|
<Link href={href} {...rest}>
|
|
{children}
|
|
</Link>
|
|
)
|
|
else
|
|
return (
|
|
<a href={href} {...rest}>
|
|
{children}
|
|
</a>
|
|
)
|
|
}
|
|
|
|
export default HybridLink
|