import React from 'react'; import { Link } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; const useStyles = makeStyles((theme) => ({ tag: { color: theme.palette.text.secondary, }, })); const AnchorTag = ({ children, href }: React.HTMLProps) => { const classes = useStyles(); const origin = window.location.origin; const destination = href === undefined ? '' : href; const isInternalLink = destination.startsWith('/') || destination.startsWith(origin); const internalDestination = destination.replace(origin, ''); const internalLink = ( {children} ); const externalLink = ( {children} ); return isInternalLink ? internalLink : externalLink; }; export default AnchorTag;