personal-website/components/HybridLink.tsx
Filipe Medeiros 9a9638237f
feat: initial commit
Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
2023-12-03 12:25:52 +01:00

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