-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): add prev. and next navigation links
- Loading branch information
1 parent
897affb
commit 5b13174
Showing
3 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use client' | ||
|
||
import { Link } from '@tszhong0411/ui' | ||
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react' | ||
import { usePathname } from 'next/navigation' | ||
|
||
import { SIDEBAR_LINKS } from '@/config/links' | ||
|
||
const DocsNavigation = () => { | ||
const pathname = usePathname() | ||
const links = SIDEBAR_LINKS.flatMap((s) => s.links) | ||
|
||
const currentIndex = links.findIndex((link) => link.href === pathname) | ||
const prevLink = links[currentIndex - 1] ?? null | ||
const nextLink = links[currentIndex + 1] ?? null | ||
|
||
return ( | ||
<nav aria-label='Documentation navigation' className='flex justify-between'> | ||
{prevLink ? ( | ||
<Link href={prevLink.href} className='group flex items-center gap-1.5' variant='muted'> | ||
<ChevronLeftIcon className='size-4 transition-transform group-hover:-translate-x-0.5' /> | ||
<span>{prevLink.text}</span> | ||
</Link> | ||
) : ( | ||
<div /> | ||
)} | ||
{nextLink ? ( | ||
<Link href={nextLink.href} className='group flex items-center gap-1.5' variant='muted'> | ||
<span>{nextLink.text}</span> | ||
<ChevronRightIcon className='size-4 transition-transform group-hover:translate-x-0.5' /> | ||
</Link> | ||
) : ( | ||
<div /> | ||
)} | ||
</nav> | ||
) | ||
} | ||
|
||
export default DocsNavigation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters