nx/nx-dev/ui-markdoc/src/lib/nodes/link.component.tsx
2022-06-30 15:30:38 -04:00

19 lines
401 B
TypeScript

import Link from 'next/link';
export function CustomLink(props: any) {
const target =
props.target || (props.href.startsWith('http') ? '_blank' : undefined);
return (
<Link {...props} passHref>
<a
target={target}
rel={target === '_blank' ? 'noreferrer' : undefined}
className={props.className}
>
{props.children}
</a>
</Link>
);
}