Skip to content

Commit fb4f3bc

Browse files
authored
feat: Mark external links in sidebar with an icon (#360)
* feat: Mark external links with an icon * Also mark "Protocol Registry" as external
1 parent c3874a3 commit fb4f3bc

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/app/docs/layout.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const navItems = [
1717
links: [
1818
{title: 'Overview', href: '/docs/overview'},
1919
{title: 'Quickstart', href: '/docs/quickstart'},
20-
{title: 'Tour', href: '/docs/tour' },
20+
{title: 'Tour', href: '/docs/tour'},
2121
{title: 'Examples', href: '/docs/examples'},
2222
],
2323
},
@@ -34,11 +34,11 @@ export const navItems = [
3434
},
3535
{title: 'Resources',
3636
links: [
37-
{title: 'Protocol Registry', href: '/proto'},
37+
{title: 'Protocol Registry', href: '/proto', external: true},
3838
{title: 'Write your own Protocol', href: '/docs/protocols/writing'},
39-
{title: 'Awesome List', href: 'https://github.com/n0-computer/awesome-iroh'},
40-
{title: 'FAQ', href: '/docs/faq' },
41-
{title: 'Wasm/Browser Support', href: '/docs/wasm-browser-support' },
39+
{title: 'Awesome List', href: 'https://github.com/n0-computer/awesome-iroh', external: true},
40+
{title: 'FAQ', href: '/docs/faq'},
41+
{title: 'Wasm/Browser Support', href: '/docs/wasm-browser-support'},
4242
],
4343
},
4444
];

src/components/Libraries.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Image from 'next/image';
2-
import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid'
2+
import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid';
33

44
import {Button} from '@/components/Button';
55
import {Heading} from '@/components/Heading';

src/components/Navigation.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Link from 'next/link';
55
import {usePathname} from 'next/navigation';
66
import clsx from 'clsx';
77
import {AnimatePresence, motion, useIsPresent} from 'framer-motion';
8+
import { ArrowTopRightOnSquareIcon } from '@heroicons/react/20/solid';
89

910
import {useIsInsideMobileNavigation} from '@/components/MobileNavigation';
1011
import {useSectionStore} from '@/components/SectionProvider';
@@ -29,7 +30,7 @@ function TopLevelNavItem({href, children}) {
2930
);
3031
}
3132

32-
function NavLink({href, tag, active, isAnchorLink = false, children}) {
33+
function NavLink({href, tag, active, isAnchorLink = false, external, children}) {
3334
return (
3435
<Link
3536
href={href}
@@ -42,7 +43,10 @@ function NavLink({href, tag, active, isAnchorLink = false, children}) {
4243
'text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white',
4344
)}
4445
>
45-
<span className="truncate">{children}</span>
46+
<span className="truncate inline-flex">
47+
{children}
48+
{external && <ArrowTopRightOnSquareIcon className="w-4 h-4 mt-1 ml-1" />}
49+
</span>
4650
{tag && (
4751
<Tag variant="small" color="zinc">
4852
{tag}
@@ -145,7 +149,7 @@ function NavigationGroup({group, className}) {
145149
<ul role="list" className="border-l border-transparent">
146150
{group.links.map((link) => (
147151
<motion.li key={link.href} layout="position" className="relative">
148-
<NavLink href={link.href} active={link.href === pathname}>
152+
<NavLink active={link.href === pathname} {...link}>
149153
{link.title}
150154
</NavLink>
151155
<AnimatePresence mode="popLayout" initial={false}>

0 commit comments

Comments
 (0)