export const dynamic = "force-dynamic"; import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getVaContent, getVaSidebarItems, type VaSidebarItem, } from "@/lib/va"; import { getProseChapter } from "@/lib/api"; import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/layout/page-header"; import { JsonLd } from "@/components/seo/json-ld"; import { articleJsonLd } from "@/lib/jsonld"; 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/layout/mobile-nav"; import { FindInPage } from "@/components/layout/find-in-page"; // --------------------------------------------------------------------------- // Metadata // --------------------------------------------------------------------------- export async function generateMetadata({ params, searchParams, }: { params: Promise<{ chapter: string }>; searchParams: Promise>; }): Promise { const { chapter: slug } = await params; const sp = await searchParams; const chapter = await getProseChapter("va", 0, slug); const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); if (hlQuote) { return buildOgMeta({ title: BOOK_NAMES["va"], quote: hlQuote }); } return ogForChapter("va", chapter?.title || ""); } // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- export default async function VaChapterPage({ params, }: { params: Promise<{ chapter: string }>; }) { const { chapter: slug } = await params; const content = await getVaContent(slug); if (!content) notFound(); const sidebarItems = await getVaSidebarItems(); 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; return (
← Vaiśiṣṭyāṣṭakam

{content.title}

{content.paragraphs.map((paragraph, i) => (
))}
); } function VaSidebar({ items, currentSlug, }: { items: VaSidebarItem[]; currentSlug: string; }) { return ( ); } function VaNav({ prev, next, sidebarItems, currentSlug, }: { prev: VaSidebarItem | null; next: VaSidebarItem | null; sidebarItems: VaSidebarItem[]; currentSlug: string; }) { const mobileNavGroups: MobileNavGroup[] = []; if (sidebarItems.length > 0) { mobileNavGroups.push({ title: "Chapters", items: sidebarItems.map((i) => ({ slug: i.slug, label: i.label, href: `/books/va/${i.slug}`, type: i.type, })), }); } return (
{prev ? ( {prev.label} Previous ) : (
)}
{next ? ( {next.label} Next ) : (
)}
); }