import React from 'react'; import PropTypes from 'prop-types'; import { Link as GatsbyLink } from 'gatsby'; const propTypes = { children: PropTypes.any, external: PropTypes.bool, sameTab: PropTypes.bool, to: PropTypes.string.isRequired }; const Link = ({ children, to, external, sameTab, ...other }) => { if (!external && /^\/(?!\/)/.test(to)) { return ( {children} ); } else if (sameTab && external) { return ( {children} ); } return ( {children} ); }; Link.propTypes = propTypes; export default Link;