getNextPage() — supabase Function Reference
Architecture documentation for the getNextPage() function in get-next-page.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD 9cb78d4b_2172_d6ab_70f8_56230d9462ce["getNextPage()"] 6925281d_d060_1098_fe37_526e0c6321ea["DocPage()"] 6925281d_d060_1098_fe37_526e0c6321ea -->|calls| 9cb78d4b_2172_d6ab_70f8_56230d9462ce aede3fb6_ba0d_36b2_0688_210bdb8ec683["flattenNavItems()"] 9cb78d4b_2172_d6ab_70f8_56230d9462ce -->|calls| aede3fb6_ba0d_36b2_0688_210bdb8ec683 d6535fbd_6a76_7688_ffe1_473fd62b482c["normalizeSlug()"] 9cb78d4b_2172_d6ab_70f8_56230d9462ce -->|calls| d6535fbd_6a76_7688_ffe1_473fd62b482c style 9cb78d4b_2172_d6ab_70f8_56230d9462ce fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/learn/lib/get-next-page.ts lines 35–82
export function getNextPage(
currentSlug: string
): { title: string; href: string; description?: string; chapterNumber?: number } | null {
// Flatten all navigation items
const allPages = flattenNavItems(courses.items)
// Normalize the current slug for comparison
const normalizedCurrentSlug = normalizeSlug(currentSlug)
// Find the current page index
const currentIndex = allPages.findIndex((page) => {
if (!page.href) return false
const pageSlug = normalizeSlug(page.href)
return pageSlug === normalizedCurrentSlug
})
// If current page not found or it's the last page, return null
if (currentIndex === -1 || currentIndex === allPages.length - 1) {
return null
}
// Get the next page
const nextPage = allPages[currentIndex + 1]
if (!nextPage || !nextPage.href) {
return null
}
// Try to get description and chapterNumber from the doc
const nextPageSlug = normalizeSlug(nextPage.href)
const doc = allDocs.find((doc) => normalizeSlug(doc.slugAsParams) === nextPageSlug)
const description = doc?.description || nextPage.title
// Get chapterNumber from frontmatter first, then fallback to parsing from title
// Using type assertion since contentlayer types may need regeneration
let chapterNumber: number | undefined = (doc as any)?.chapterNumber
if (!chapterNumber) {
// Try to extract chapter number from title (e.g., "2: CSS Styling" -> 2)
const chapterMatch = nextPage.title.match(/^(\d+):/)
chapterNumber = chapterMatch ? parseInt(chapterMatch[1], 10) : undefined
}
return {
title: nextPage.title,
href: nextPage.href,
description,
chapterNumber,
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getNextPage() do?
getNextPage() is a function in the supabase codebase.
What does getNextPage() call?
getNextPage() calls 2 function(s): flattenNavItems, normalizeSlug.
What calls getNextPage()?
getNextPage() is called by 1 function(s): DocPage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free