From 5cb5827f1c15d2a5966a9412d08763feea8a4e34 Mon Sep 17 00:00:00 2001 From: gosangam Date: Thu, 7 May 2026 19:34:04 +0530 Subject: [PATCH] feat: add metadata generator for remaining books --- app/books/bg/[chapter]/page.tsx | 14 ++++++++++++ app/books/bs/[chapter]/page.tsx | 14 ++++++++++++ app/books/mm/[chapter]/page.tsx | 14 ++++++++++++ app/books/mog/[chapter]/page.tsx | 27 +++++++++++++++++++++- app/books/nbs/[chapter]/page.tsx | 17 ++++++++++++++ app/books/nod/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/ochkm/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/owk/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/pk/[chapter]/page.tsx | 35 +++++++++++++++++++++++------ app/books/poy/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/pqpa/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/rv/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/sb1962/[chapter]/page.tsx | 17 ++++++++++++++ app/books/ssr/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/sva/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/tlc/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/tlk/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/tqk/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/ttp/[chapter]/page.tsx | 27 ++++++++++++++++++++++ app/books/va/[chapter]/page.tsx | 29 ++++++++++++++++++++++++ 20 files changed, 483 insertions(+), 8 deletions(-) diff --git a/app/books/bg/[chapter]/page.tsx b/app/books/bg/[chapter]/page.tsx index ef20651a..28e0fd3a 100644 --- a/app/books/bg/[chapter]/page.tsx +++ b/app/books/bg/[chapter]/page.tsx @@ -1,6 +1,20 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { notFound } from "next/navigation"; import { getChapterVerseIndex } from "@/lib/api"; +import { buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; + +export async function generateMetadata({ + params, +}: { + params: Promise<{ chapter: string }>; +}): Promise { + const { chapter } = await params; + return buildOgMeta({ title: BOOK_NAMES["bg"], detail: `Chapter ${chapter}` }); +} export default async function ChapterPage({ params, diff --git a/app/books/bs/[chapter]/page.tsx b/app/books/bs/[chapter]/page.tsx index 148c8ba2..0d3b6fba 100644 --- a/app/books/bs/[chapter]/page.tsx +++ b/app/books/bs/[chapter]/page.tsx @@ -1,6 +1,11 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { notFound } from "next/navigation"; import { getChapterVerseIndex } from "@/lib/api"; +import { buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { Card, CardContent } from "@/components/ui/card"; import { PageHeader } from "@/components/page-header"; import Link from "next/link"; @@ -15,6 +20,15 @@ type IntroSegment = { paragraphs: string[]; }; +export async function generateMetadata({ + params, +}: { + params: Promise<{ chapter: string }>; +}): Promise { + const { chapter } = await params; + return buildOgMeta({ title: BOOK_NAMES["bs"], detail: `Chapter ${chapter}` }); +} + export default async function BsChapterPage({ params, }: { diff --git a/app/books/mm/[chapter]/page.tsx b/app/books/mm/[chapter]/page.tsx index 4cb73cce..30f2048f 100644 --- a/app/books/mm/[chapter]/page.tsx +++ b/app/books/mm/[chapter]/page.tsx @@ -1,6 +1,11 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { notFound } from "next/navigation"; import { getChapterVerseIndex } from "@/lib/api"; +import { buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { Card, CardContent } from "@/components/ui/card"; import { PageHeader } from "@/components/page-header"; import Link from "next/link"; @@ -15,6 +20,15 @@ type IntroSegment = { paragraphs: string[]; }; +export async function generateMetadata({ + params, +}: { + params: Promise<{ chapter: string }>; +}): Promise { + const { chapter } = await params; + return buildOgMeta({ title: BOOK_NAMES["mm"], detail: `Chapter ${chapter}` }); +} + export default async function MmChapterPage({ params, }: { diff --git a/app/books/mog/[chapter]/page.tsx b/app/books/mog/[chapter]/page.tsx index dc45b946..1141aa48 100644 --- a/app/books/mog/[chapter]/page.tsx +++ b/app/books/mog/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type MogChapter, type MogSidebarItem, } from "@/lib/mog"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,7 +19,26 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; -export const dynamic = "force-dynamic"; +// --------------------------------------------------------------------------- +// 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("mog", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["mog"], quote: hlQuote }); + } + return ogForChapter("mog", chapter?.title || ""); +} // --------------------------------------------------------------------------- // Page diff --git a/app/books/nbs/[chapter]/page.tsx b/app/books/nbs/[chapter]/page.tsx index eecd61db..aac93e1f 100644 --- a/app/books/nbs/[chapter]/page.tsx +++ b/app/books/nbs/[chapter]/page.tsx @@ -1,6 +1,11 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { notFound } from "next/navigation"; import { getChapterVerseIndex } from "@/lib/api"; +import { buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { Card, CardContent } from "@/components/ui/card"; import { PageHeader } from "@/components/page-header"; import Link from "next/link"; @@ -15,6 +20,18 @@ type IntroSegment = { paragraphs: string[]; }; +export async function generateMetadata({ + params, +}: { + params: Promise<{ chapter: string }>; +}): Promise { + const { chapter } = await params; + return buildOgMeta({ + title: BOOK_NAMES["nbs"], + detail: `Chapter ${chapter}`, + }); +} + export default async function NbsChapterPage({ params, }: { diff --git a/app/books/nod/[chapter]/page.tsx b/app/books/nod/[chapter]/page.tsx index fb50b00d..90da49b2 100644 --- a/app/books/nod/[chapter]/page.tsx +++ b/app/books/nod/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type NodChapter, type NodSidebarItem, } from "@/lib/nod"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("nod", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["nod"], quote: hlQuote }); + } + return ogForChapter("nod", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/ochkm/[chapter]/page.tsx b/app/books/ochkm/[chapter]/page.tsx index 6894268d..2c129a73 100644 --- a/app/books/ochkm/[chapter]/page.tsx +++ b/app/books/ochkm/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type OchkmChapter, type OchkmSidebarItem, } from "@/lib/ochkm"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("ochkm", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["ochkm"], quote: hlQuote }); + } + return ogForChapter("ochkm", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/owk/[chapter]/page.tsx b/app/books/owk/[chapter]/page.tsx index 47fec633..8bea2b20 100644 --- a/app/books/owk/[chapter]/page.tsx +++ b/app/books/owk/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type OwkChapter, type OwkSidebarItem, } from "@/lib/owk"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("owk", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["owk"], quote: hlQuote }); + } + return ogForChapter("owk", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/pk/[chapter]/page.tsx b/app/books/pk/[chapter]/page.tsx index 52389f70..b81b1050 100644 --- a/app/books/pk/[chapter]/page.tsx +++ b/app/books/pk/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type PkChapter, type PkSidebarItem, } from "@/lib/pk"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,7 +19,26 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; -export const dynamic = "force-dynamic"; +// --------------------------------------------------------------------------- +// 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("pk", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["pk"], quote: hlQuote }); + } + return ogForChapter("pk", chapter?.title || ""); +} // --------------------------------------------------------------------------- // Page @@ -204,9 +229,7 @@ function PkNav({ > - {prev.chapter != null - ? `Prayer ${prev.chapter}` - : prev.label} + {prev.chapter != null ? `Prayer ${prev.chapter}` : prev.label} Previous @@ -224,9 +247,7 @@ function PkNav({ )} > - {next.chapter != null - ? `Prayer ${next.chapter}` - : next.label} + {next.chapter != null ? `Prayer ${next.chapter}` : next.label} Next diff --git a/app/books/poy/[chapter]/page.tsx b/app/books/poy/[chapter]/page.tsx index 93a75713..672d9526 100644 --- a/app/books/poy/[chapter]/page.tsx +++ b/app/books/poy/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type PoyChapter, type PoySidebarItem, } from "@/lib/poy"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("poy", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["poy"], quote: hlQuote }); + } + return ogForChapter("poy", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/pqpa/[chapter]/page.tsx b/app/books/pqpa/[chapter]/page.tsx index f7da9ae9..70c69f44 100644 --- a/app/books/pqpa/[chapter]/page.tsx +++ b/app/books/pqpa/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type PqpaChapter, type PqpaSidebarItem, } from "@/lib/pqpa"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("pqpa", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["pqpa"], quote: hlQuote }); + } + return ogForChapter("pqpa", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/rv/[chapter]/page.tsx b/app/books/rv/[chapter]/page.tsx index 4a3ae792..53d36ba3 100644 --- a/app/books/rv/[chapter]/page.tsx +++ b/app/books/rv/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type RvChapter, type RvSidebarItem, } from "@/lib/rv"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("rv", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["rv"], quote: hlQuote }); + } + return ogForChapter("rv", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/sb1962/[chapter]/page.tsx b/app/books/sb1962/[chapter]/page.tsx index 2484e869..3b1c000a 100644 --- a/app/books/sb1962/[chapter]/page.tsx +++ b/app/books/sb1962/[chapter]/page.tsx @@ -1,6 +1,23 @@ +import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { notFound } from "next/navigation"; import { getChapterVerseIndex } from "@/lib/api"; +import { buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; + +export const dynamic = "force-dynamic"; + +export async function generateMetadata({ + params, +}: { + params: Promise<{ chapter: string }>; +}): Promise { + const { chapter } = await params; + return buildOgMeta({ + title: BOOK_NAMES["sb1962"], + detail: `Chapter ${chapter}`, + }); +} export default async function ChapterPage({ params, diff --git a/app/books/ssr/[chapter]/page.tsx b/app/books/ssr/[chapter]/page.tsx index c2e44d23..b09b856b 100644 --- a/app/books/ssr/[chapter]/page.tsx +++ b/app/books/ssr/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type SsrChapter, type SsrSidebarItem, } from "@/lib/ssr"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("ssr", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["ssr"], quote: hlQuote }); + } + return ogForChapter("ssr", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/sva/[chapter]/page.tsx b/app/books/sva/[chapter]/page.tsx index 85564698..799f7228 100644 --- a/app/books/sva/[chapter]/page.tsx +++ b/app/books/sva/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -7,6 +10,9 @@ import { type SvaChapter, type SvaSidebarItem, } from "@/lib/sva"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -14,6 +20,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("sva", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["sva"], quote: hlQuote }); + } + return ogForChapter("sva", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/tlc/[chapter]/page.tsx b/app/books/tlc/[chapter]/page.tsx index 1cf0a7de..725c759a 100644 --- a/app/books/tlc/[chapter]/page.tsx +++ b/app/books/tlc/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type TlcChapter, type TlcSidebarItem, } from "@/lib/tlc"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("tlc", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["tlc"], quote: hlQuote }); + } + return ogForChapter("tlc", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/tlk/[chapter]/page.tsx b/app/books/tlk/[chapter]/page.tsx index 106debf3..17b3cafa 100644 --- a/app/books/tlk/[chapter]/page.tsx +++ b/app/books/tlk/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type TlkChapter, type TlkSidebarItem, } from "@/lib/tlk"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("tlk", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["tlk"], quote: hlQuote }); + } + return ogForChapter("tlk", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/tqk/[chapter]/page.tsx b/app/books/tqk/[chapter]/page.tsx index 793e43ef..3a6a09d0 100644 --- a/app/books/tqk/[chapter]/page.tsx +++ b/app/books/tqk/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type TqkChapter, type TqkSidebarItem, } from "@/lib/tqk"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("tqk", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["tqk"], quote: hlQuote }); + } + return ogForChapter("tqk", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/ttp/[chapter]/page.tsx b/app/books/ttp/[chapter]/page.tsx index de4a3af5..799822dc 100644 --- a/app/books/ttp/[chapter]/page.tsx +++ b/app/books/ttp/[chapter]/page.tsx @@ -1,3 +1,6 @@ +export const dynamic = "force-dynamic"; + +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -6,6 +9,9 @@ import { type TtpChapter, type TtpSidebarItem, } from "@/lib/ttp"; +import { getProseChapter } from "@/lib/api"; +import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og"; +import { BOOK_NAMES } from "@/lib/constants"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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("ttp", 0, slug); + const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs); + if (hlQuote) { + return buildOgMeta({ title: BOOK_NAMES["ttp"], quote: hlQuote }); + } + return ogForChapter("ttp", chapter?.title || ""); +} + // --------------------------------------------------------------------------- // Page // --------------------------------------------------------------------------- diff --git a/app/books/va/[chapter]/page.tsx b/app/books/va/[chapter]/page.tsx index 1b5c5a14..6325833c 100644 --- a/app/books/va/[chapter]/page.tsx +++ b/app/books/va/[chapter]/page.tsx @@ -1,5 +1,6 @@ export const dynamic = "force-dynamic"; +import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { @@ -8,6 +9,9 @@ import { type VaChapter, 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/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; @@ -15,6 +19,31 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; +// --------------------------------------------------------------------------- +// 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, }: {