Skip to content

Commit

Permalink
docs: NavList example with next/link's URL object (#2203)
Browse files Browse the repository at this point in the history
Adding another use-case in the NavList's NextJS example
  • Loading branch information
wiinci committed Jul 29, 2022
1 parent 4d9b7db commit e0113df
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/content/NavList.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ import {NavList} from '@primer/react'

function NavItem({href, children}) {
const router = useRouter()
const isCurrent = router.asPath === href
const isCurrent =
typeof href === 'string'
? router.asPath === href
: router.pathname === href.pathname;
return (
<Link href={href} passHref>
<NavList.Item aria-current={isCurrent ? 'page' : false}>{children}</NavList.Item>
Expand All @@ -224,6 +227,14 @@ function App() {
<NavItem href="/">Dashboard</NavItem>
<NavItem href="/pulls">Pull requests</NavItem>
<NavItem href="/issues">Issues</NavItem>
<NavItem
href={{
pathname: '/[owner]/[repo]',
query: { owner, repo },
}}
>
Summary
</NavItem>
</NavList>
)
}
Expand Down

0 comments on commit e0113df

Please sign in to comment.