Roadmap to becoming a developer in 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
555 B

import React from 'react';
3 years ago
import styled from 'styled-components';
type EnrichedLinkProps = {
href: string;
children: React.ReactNode
}
3 years ago
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 (
3 years ago
<Link href={props.href} target={isExternalUrl ? '_blank' : '_self'}>
{props.children}
</Link>
);
};
3 years ago
export default EnrichedLink;