import Link from "next/link"; import { notFound } from "next/navigation"; import { getPkContent, getPkSidebarItems, type PkChapter, type PkSidebarItem, } from "@/lib/pk"; 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"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; export const dynamic = "force-dynamic"; // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- export default async function PkChapterPage({ params, }: { params: Promise<{ chapter: string }>; }) { const { chapter: slug } = await params; const content = await getPkContent(slug); if (!content) notFound(); const sidebarItems = await getPkSidebarItems(); 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; const chapterNum = (content as PkChapter).chapter; return (
← Prayers of King Kulaśekhara

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

{/* Left sidebar */} {/* Main content */}
{/* Top navigation */} {/* Content */}
{content.paragraphs.map((paragraph, i) => (
))}
{/* Bottom navigation */}
); } // --------------------------------------------------------------------------- // Sidebar // --------------------------------------------------------------------------- function PkSidebar({ items, currentSlug, }: { items: PkSidebarItem[]; currentSlug: string; }) { const chapterItems = items.filter((item) => item.type === "chapter"); return ( ); } function SidebarLink({ item, isActive, }: { item: PkSidebarItem; isActive: boolean; }) { return ( {item.label} ); } // --------------------------------------------------------------------------- // Prev / Next navigation // --------------------------------------------------------------------------- function PkNav({ prev, next, sidebarItems, currentSlug, }: { prev: PkSidebarItem | null; next: PkSidebarItem | null; sidebarItems: PkSidebarItem[]; currentSlug: string; }) { const mobileNavGroups: MobileNavGroup[] = []; const chapterItems = sidebarItems.filter((i) => i.type === "chapter"); if (chapterItems.length > 0) { mobileNavGroups.push({ title: "Prayers", items: chapterItems.map((i) => ({ slug: i.slug, label: i.label, href: `/books/pk/${i.slug}`, type: i.type, })), }); } return (
{prev ? ( {prev.chapter != null ? `Prayer ${prev.chapter}` : prev.label} Previous ) : (
)}
{next ? ( {next.chapter != null ? `Prayer ${next.chapter}` : next.label} Next ) : (
)}
); }