chore: heygermany customer project
This commit is contained in:
18
apps/website/framework/link.tsx
Normal file
18
apps/website/framework/link.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
Reference in New Issue
Block a user