Files
developer-roadmap/components/md-renderer/mdx-components/a.tsx

19 lines
504 B
TypeScript
Raw Normal View History

2021-08-20 17:06:26 +02:00
import React from 'react';
import { Link } from '@chakra-ui/react';
type EnrichedLinkProps = {
href: string;
children: React.ReactNode
}
export default function EnrichedLink(props: EnrichedLinkProps) {
// Is external URL or is a media URL
const isExternalUrl = /(^http(s)?:\/\/)|(\.(png|svg|jpeg|jpg)$)/.test(props.href);
return (
2021-08-22 15:36:03 +02:00
<Link fontWeight={600} href={props.href} target={isExternalUrl ? '_blank' : '_self'} textDecoration='underline'>
2021-08-20 17:06:26 +02:00
{props.children}
</Link>
);
};