Browse Source

[Beta] Open external link in new tab

main
Dan Abramov 2 years ago
parent
commit
5f349ddda7
  1. 5
      beta/src/components/Layout/Sidebar/SidebarLink.tsx
  2. 8
      beta/src/sidebarHome.json

5
beta/src/components/Layout/Sidebar/SidebarLink.tsx

@ -47,11 +47,16 @@ export function SidebarLink({
} }
}, [ref, selected]); }, [ref, selected]);
let target = '';
if (href.startsWith('https://')) {
target = '_blank';
}
return ( return (
<Link href={href}> <Link href={href}>
<a <a
ref={ref} ref={ref}
title={title} title={title}
target={target}
aria-current={selected ? 'page' : undefined} aria-current={selected ? 'page' : undefined}
className={cn( className={cn(
'p-2 pr-2 w-full rounded-none lg:rounded-r-lg text-left hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between', 'p-2 pr-2 w-full rounded-none lg:rounded-r-lg text-left hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',

8
beta/src/sidebarHome.json

@ -11,10 +11,6 @@
"title": "Overview", "title": "Overview",
"path": "/" "path": "/"
}, },
{
"title": "Blog",
"path": "https://reactjs.org/blog"
},
{ {
"title": "Community", "title": "Community",
"path": "/community", "path": "/community",
@ -25,6 +21,10 @@
"title": "Meet the Team", "title": "Meet the Team",
"path": "/community/meet-the-team" "path": "/community/meet-the-team"
}] }]
},
{
"title": "Blog",
"path": "https://reactjs.org/blog"
} }
] ]
} }

Loading…
Cancel
Save