Files
e2e 9c39da4d3f
Some checks failed
Main / Setup and Test (push) Has been cancelled
Main / Build Website (push) Has been cancelled
chore: heygermany customer project
2026-07-11 08:26:01 +02:00

19 lines
542 B
TypeScript

import { forwardRef, type AnchorHTMLAttributes } from 'react'
import { Link as RouterLink } from '@tanstack/react-router'
export type LinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
href: string
}
const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(props, ref) {
const { href, ...rest } = props
if (/^(https?:|mailto:|tel:)/.test(href)) {
return <a ref={ref} href={href} {...rest} />
}
return <RouterLink ref={ref} to={href as never} {...(rest as Record<string, unknown>)} />
})
export default Link