Skip to content

Commit 2465ec6

Browse files
authored
fix: open blog link in new window (#2211)
1 parent 0d9f929 commit 2465ec6

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

packages/website/components/link.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ import Link from 'next/link'
77
* @param {string} [props.className]
88
* @param {number} [props.tabIndex]
99
* @param {string} [props.id]
10+
* @param {string} [props.target]
1011
* @param {React.MouseEventHandler} [props.onClick]
1112
* @param {React.ReactNode | string} props.children
1213
* @returns {JSX.Element}
1314
*/
14-
const WrappedLink = ({ tabIndex = 0, href = '', children, ...otherProps }) => (
15-
<Link href={href} {...otherProps}>
15+
const WrappedLink = ({
16+
tabIndex = 0,
17+
href = '',
18+
children,
19+
target,
20+
...otherProps
21+
}) => (
22+
<Link href={href} {...otherProps} passHref={target === '_blank'}>
1623
<a
1724
href={href.pathname || href}
1825
{...otherProps}
26+
target={target}
1927
tabIndex={tabIndex}
2028
onClick={otherProps.onClick}
2129
>

packages/website/components/navbar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export default function Navbar({ bgColor = 'bg-nsorange', logo, user }) {
103103
pathname: BLOG_URL,
104104
activeClass: '!text-forest',
105105
},
106+
target: '_blank',
106107
name: 'Blog',
107108
},
108109
...(user
@@ -183,6 +184,7 @@ export default function Navbar({ bgColor = 'bg-nsorange', logo, user }) {
183184
href={item.link || ''}
184185
key={item.name}
185186
aria-current={isActive ? 'page' : undefined}
187+
target={item.target}
186188
className={clsx(
187189
'text-xl text-black no-underline underline-hover align-middle',
188190
{
@@ -264,6 +266,7 @@ export default function Navbar({ bgColor = 'bg-nsorange', logo, user }) {
264266
'mobile-nav-link align-middle chicagoflf',
265267
logo.isDark ? 'black' : 'white'
266268
)}
269+
target={item.target}
267270
onClick={item.tracking ? item.tracking : onMobileLinkClick}
268271
>
269272
{item.name}

0 commit comments

Comments
 (0)