2019-11-02 17:50:57 +04:00
|
|
|
import styled from 'styled-components';
|
|
|
|
|
|
|
|
const Link = styled.a`
|
|
|
|
font-weight: 600;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const EnrichedLink = props => {
|
2020-04-24 20:45:32 +04:00
|
|
|
// Is external URL or is a media URL
|
|
|
|
const isExternalUrl = /(^http(s)?:\/\/)|(\.(png|svg|jpeg|jpg)$)/.test(props.href);
|
|
|
|
|
2019-11-02 17:50:57 +04:00
|
|
|
return (
|
2020-04-24 20:45:32 +04:00
|
|
|
<Link href={ props.href } target={ isExternalUrl ? '_blank' : '_self' }>
|
2019-11-02 17:50:57 +04:00
|
|
|
{ props.children }
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-04-24 20:45:32 +04:00
|
|
|
export default EnrichedLink;
|