import Link from "next/link"; import { notFound } from "next/navigation"; import { getRvContent, getRvSidebarItems, type RvChapter, type RvSidebarItem, } from "@/lib/rv"; 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 RvChapterPage({ params, }: { params: Promise<{ chapter: string }>; }) { const { chapter: slug } = await params; const content = await getRvContent(slug); if (!content) notFound(); const sidebarItems = await getRvSidebarItems(); 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 RvChapter).chapter === "number" && (content as RvChapter).chapter !== null; const chapterNum = isChapter ? (content as RvChapter).chapter : null; return (
← Rāja-vidyā: The King of Knowledge

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

{/* Left sidebar */} {/* Main content */}
{/* Top navigation */} {/* Content */}
{content.paragraphs.map((paragraph, i) => (
))}
{/* Bottom navigation */}
); } // --------------------------------------------------------------------------- // Sidebar // --------------------------------------------------------------------------- function RvSidebar({ items, currentSlug, }: { items: RvSidebarItem[]; 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: RvSidebarItem; isActive: boolean; }) { return ( {item.label} ); } // --------------------------------------------------------------------------- // Prev / Next navigation // --------------------------------------------------------------------------- function RvNav({ prev, next, }: { prev: RvSidebarItem | null; next: RvSidebarItem | 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 ) : (
)}
); }