fix: open universal nav links on the same tab (#38273)
This commit is contained in:
@ -15,12 +15,12 @@ function NavLinks({ displayMenu }) {
|
||||
role='menu'
|
||||
>
|
||||
<li className='nav-news' role='menuitem'>
|
||||
<Link external={true} to='/news'>
|
||||
<Link external={true} sameTab={true} to='/news'>
|
||||
/news
|
||||
</Link>
|
||||
</li>
|
||||
<li className='nav-forum' role='menuitem'>
|
||||
<Link external={true} to='/forum'>
|
||||
<Link external={true} sameTab={true} to='/forum'>
|
||||
/forum
|
||||
</Link>
|
||||
</li>
|
||||
|
@ -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