Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 84c3d90

Browse files
committed
handle external pages in nav link
1 parent e7bed00 commit 84c3d90

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/nav/NavLink.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ export const NavLink: React.FC<NavLinkProps> = ({
2222
icon: Icon,
2323
className,
2424
}) => {
25+
const isExternal = href.startsWith('http')
26+
2527
return (
2628
<Button variant="link" asChild>
2729
<Link
2830
href={href}
2931
aria-current={active ? 'page' : undefined}
32+
target={isExternal ? '_blank' : undefined}
33+
rel={isExternal ? 'noopener noreferrer' : undefined}
3034
className={cn(
3135
'relative flex w-full justify-between gap-2 py-1 pr-3 text-sm no-underline transition hover:no-underline',
3236
isAnchorLink ? 'pl-7' : 'pl-2',

0 commit comments

Comments
 (0)