Skip to content

Commit a1141d6

Browse files
authored
docs: NavList example with next/link's URL object
Adding another use-case in the NavList's NextJS example
1 parent 4156b71 commit a1141d6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/content/NavList.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ import {NavList} from '@primer/react'
210210

211211
function NavItem({href, children}) {
212212
const router = useRouter()
213-
const isCurrent = router.asPath === href
213+
const isCurrent =
214+
typeof href === 'string'
215+
? router.asPath === href
216+
: router.pathname === href.pathname;
214217
return (
215218
<Link href={href} passHref>
216219
<NavList.Item aria-current={isCurrent ? 'page' : false}>{children}</NavList.Item>
@@ -224,6 +227,14 @@ function App() {
224227
<NavItem href="/">Dashboard</NavItem>
225228
<NavItem href="/pulls">Pull requests</NavItem>
226229
<NavItem href="/issues">Issues</NavItem>
230+
<NavItem
231+
href={{
232+
pathname: '/[owner]/[repo]',
233+
query: { owner, repo },
234+
}}
235+
>
236+
Summary
237+
</NavItem>
227238
</NavList>
228239
)
229240
}

0 commit comments

Comments
 (0)