The Node.js® Website
at main 541 B view raw
1import type { FC, ComponentProps } from 'react'; 2 3import { Link as LocalizedLink } from '@/navigation.mjs'; 4 5type LinkProps = Omit<ComponentProps<typeof LocalizedLink>, 'href'> & { 6 href?: string; 7}; 8 9const Link: FC<LinkProps> = ({ children, href, ...props }) => { 10 if (!href || href.toString().startsWith('http')) { 11 return ( 12 <a href={href} {...props}> 13 {children} 14 </a> 15 ); 16 } 17 18 return ( 19 <LocalizedLink href={href?.toString()} {...props}> 20 {children} 21 </LocalizedLink> 22 ); 23}; 24 25export default Link;