fix: open universal nav links on the same tab (#38273)
This commit is contained in:
@ -15,12 +15,12 @@ function NavLinks({ displayMenu }) {
|
|||||||
role='menu'
|
role='menu'
|
||||||
>
|
>
|
||||||
<li className='nav-news' role='menuitem'>
|
<li className='nav-news' role='menuitem'>
|
||||||
<Link external={true} to='/news'>
|
<Link external={true} sameTab={true} to='/news'>
|
||||||
/news
|
/news
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
<li className='nav-forum' role='menuitem'>
|
<li className='nav-forum' role='menuitem'>
|
||||||
<Link external={true} to='/forum'>
|
<Link external={true} sameTab={true} to='/forum'>
|
||||||
/forum
|
/forum
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
|
@ -5,16 +5,23 @@ import { Link as GatsbyLink } from 'gatsby';
|
|||||||
const propTypes = {
|
const propTypes = {
|
||||||
children: PropTypes.any,
|
children: PropTypes.any,
|
||||||
external: PropTypes.bool,
|
external: PropTypes.bool,
|
||||||
|
sameTab: PropTypes.bool,
|
||||||
to: PropTypes.string.isRequired
|
to: PropTypes.string.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
const Link = ({ children, to, external, ...other }) => {
|
const Link = ({ children, to, external, sameTab, ...other }) => {
|
||||||
if (!external && /^\/(?!\/)/.test(to)) {
|
if (!external && /^\/(?!\/)/.test(to)) {
|
||||||
return (
|
return (
|
||||||
<GatsbyLink to={to} {...other}>
|
<GatsbyLink to={to} {...other}>
|
||||||
{children}
|
{children}
|
||||||
</GatsbyLink>
|
</GatsbyLink>
|
||||||
);
|
);
|
||||||
|
} else if (sameTab && external) {
|
||||||
|
return (
|
||||||
|
<a href={to} {...other}>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user