getCurrentChapter() — supabase Function Reference
Architecture documentation for the getCurrentChapter() function in get-current-chapter.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD 5e15b528_e99b_9fad_c426_e91684a3fcbf["getCurrentChapter()"] 6925281d_d060_1098_fe37_526e0c6321ea["DocPage()"] 6925281d_d060_1098_fe37_526e0c6321ea -->|calls| 5e15b528_e99b_9fad_c426_e91684a3fcbf d6535fbd_6a76_7688_ffe1_473fd62b482c["normalizeSlug()"] 5e15b528_e99b_9fad_c426_e91684a3fcbf -->|calls| d6535fbd_6a76_7688_ffe1_473fd62b482c style 5e15b528_e99b_9fad_c426_e91684a3fcbf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/learn/lib/get-current-chapter.ts lines 7–36
export function getCurrentChapter(
slug: string
): { chapterNumber?: number; completionMessage?: string } | null {
const normalizedSlug = normalizeSlug(slug)
const doc = allDocs.find((doc) => normalizeSlug(doc.slugAsParams) === normalizedSlug)
if (!doc) {
return null
}
// Get chapterNumber from frontmatter first, then fallback to parsing from title
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 = doc.title.match(/^(\d+):/)
chapterNumber = chapterMatch ? parseInt(chapterMatch[1], 10) : undefined
}
if (!chapterNumber) {
return null
}
// Use description as completion message, or generate a default one
const completionMessage = doc.description || undefined
return {
chapterNumber,
completionMessage,
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does getCurrentChapter() do?
getCurrentChapter() is a function in the supabase codebase.
What does getCurrentChapter() call?
getCurrentChapter() calls 1 function(s): normalizeSlug.
What calls getCurrentChapter()?
getCurrentChapter() 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