fix: open universal nav links on the same tab (#38273)
This commit is contained in:
@@ -5,16 +5,23 @@ 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, ...other }) => {
|
||||
const Link = ({ children, to, external, sameTab, ...other }) => {
|
||||
if (!external && /^\/(?!\/)/.test(to)) {
|
||||
return (
|
||||
<GatsbyLink to={to} {...other}>
|
||||
{children}
|
||||
</GatsbyLink>
|
||||
);
|
||||
} else if (sameTab && external) {
|
||||
return (
|
||||
<a href={to} {...other}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user