Fix build errors

This commit is contained in:
Kamran Ahmed
2021-09-05 18:25:49 +02:00
parent 7e0a392a87
commit 6bb1505db3
8 changed files with 67 additions and 41 deletions

View File

@@ -1,18 +1,26 @@
import React from 'react';
import { Link } from '@chakra-ui/react';
import styled from 'styled-components';
type EnrichedLinkProps = {
href: string;
children: React.ReactNode
}
export default function EnrichedLink(props: EnrichedLinkProps) {
const Link = styled.a`
font-weight: 600;
text-decoration: underline;
`;
const EnrichedLink = (props: EnrichedLinkProps) => {
// Is external URL or is a media URL
const isExternalUrl = /(^http(s)?:\/\/)|(\.(png|svg|jpeg|jpg)$)/.test(props.href);
return (
<Link fontWeight={600} href={props.href} target={isExternalUrl ? '_blank' : '_self'} textDecoration='underline'>
<Link href={props.href} target={isExternalUrl ? '_blank' : '_self'}>
{props.children}
</Link>
);
};
export default EnrichedLink;