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>
|
|
|
|
);
|
|
|
|
};
|