import Link from "next/link"; import { notFound } from "next/navigation"; import { getHkhContent, getHkhSidebarItems, type HkhChapter, type HkhSidebarItem, } from "@/lib/hkh"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- export default async function HkhChapterPage({ params, }: { params: Promise<{ chapter: string }>; }) { const { chapter: slug } = await params; const content = await getHkhContent(slug); if (!content) notFound(); const sidebarItems = await getHkhSidebarItems(); const currentIdx = sidebarItems.findIndex((item) => item.slug === slug); const prev = currentIdx > 0 ? sidebarItems[currentIdx - 1] : null; const next = currentIdx < sidebarItems.length - 1 ? sidebarItems[currentIdx + 1] : null; // Build the page title const isChapter = "chapter" in content && typeof (content as HkhChapter).chapter === "number" && (content as HkhChapter).chapter !== null; const chapterNum = isChapter ? (content as HkhChapter).chapter : null; return (
← The Kṛṣṇa Consciousness Handbook

{chapterNum != null && ( Chapter {chapterNum}: )} {content.title}

{/* Left sidebar */} {/* Main content */}
{/* Top navigation */} {/* Content */}
{content.paragraphs.map((paragraph, i) => (
))}
{/* Bottom navigation */}
); } // --------------------------------------------------------------------------- // Sidebar // --------------------------------------------------------------------------- function HkhSidebar({ items, currentSlug, }: { items: HkhSidebarItem[]; currentSlug: string; }) { const introItems = items.filter((item) => item.type === "intro-segment"); const chapterItems = items.filter((item) => item.type === "chapter"); return ( ); } function SidebarLink({ item, isActive, }: { item: HkhSidebarItem; isActive: boolean; }) { return ( {item.label} ); } // --------------------------------------------------------------------------- // Prev / Next navigation // --------------------------------------------------------------------------- function HkhNav({ prev, next, }: { prev: HkhSidebarItem | null; next: HkhSidebarItem | null; }) { return (
{prev ? ( {prev.type === "chapter" && prev.chapter != null ? `Ch. ${prev.chapter}` : prev.label} Previous ) : (
)} {next ? ( {next.type === "chapter" && next.chapter != null ? `Ch. ${next.chapter}` : next.label} Next ) : (
)}
); }