Skip to content

Commit fdabfe1

Browse files
committed
docs: fix navigation
1 parent 089ad27 commit fdabfe1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

website/src/lib/pages.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { type Pages, pages } from '.velite'
44
import { getSidebarGroupsWithPages } from './sidebar'
55

66
const orderedPages = getSidebarGroupsWithPages().flatMap((group) => group.items)
7+
const uniqueOrderedPages = orderedPages.filter(
8+
(page, index, self) => self.findIndex((p) => p.slug === page.slug) === index,
9+
)
710

811
export function getPageBySlug(slug: string[], framework?: string): Pages | undefined {
912
const slugStr = slug.join('/')
@@ -21,10 +24,10 @@ export interface NavItem {
2124

2225
export function getPageNavigation(slug: string[]): { prev?: NavItem; next?: NavItem } {
2326
const slugStr = slug.join('/')
24-
const index = orderedPages.findIndex((page) => page.slug === slugStr)
27+
const index = uniqueOrderedPages.findIndex((page) => page.slug === slugStr)
2528

26-
const prevPage = orderedPages[index - 1]
27-
const nextPage = orderedPages[index + 1]
29+
const prevPage = uniqueOrderedPages[index - 1]
30+
const nextPage = uniqueOrderedPages[index + 1]
2831

2932
return {
3033
prev: prevPage ? { slug: prevPage.slug, title: prevPage.title } : undefined,

0 commit comments

Comments
 (0)