diff --git a/app/(app)/books/bg/[chapter]/page.tsx b/app/(app)/books/bg/[chapter]/page.tsx index 28e0fd3a..a046d104 100644 --- a/app/(app)/books/bg/[chapter]/page.tsx +++ b/app/(app)/books/bg/[chapter]/page.tsx @@ -3,9 +3,13 @@ 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 Link from "next/link"; +import { getChapterVerseIndex, getProseChapter } 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/layout/page-header"; +import { FindInPage } from "@/components/layout/find-in-page"; export async function generateMetadata({ params, @@ -13,6 +17,14 @@ export async function generateMetadata({ params: Promise<{ chapter: string }>; }): Promise { const { chapter } = await params; + // Non-numeric segments are front matter (dedication, foreword, …). + if (isNaN(parseInt(chapter))) { + const segment = await getProseChapter("bg", 0, chapter); + return buildOgMeta({ + title: BOOK_NAMES["bg"], + detail: segment?.title ?? "Front Matter", + }); + } return buildOgMeta({ title: BOOK_NAMES["bg"], detail: `Chapter ${chapter}` }); } @@ -22,6 +34,50 @@ export default async function ChapterPage({ params: Promise<{ chapter: string }>; }) { const { chapter } = await params; + + // Front matter — non-numeric slugs (dedication, foreword, preface, + // introduction, disciplic-succession) resolve to prose intro-segments. + if (isNaN(parseInt(chapter))) { + const segment = await getProseChapter("bg", 0, chapter); + if (!segment) notFound(); + + return ( +
+ + + ← {BOOK_NAMES["bg"]} + +
+

+ {segment.title} +

+ +
+
+ +
+ + +
+ {segment.paragraphs.map((paragraph, i) => ( +
+ ))} +
+ + +
+
+ ); + } + + // Numeric chapters — redirect to the first verse. const verseIndex = await getChapterVerseIndex("bg", null, parseInt(chapter)); if (verseIndex.length === 0) { notFound(); diff --git a/app/(app)/books/bg/page.tsx b/app/(app)/books/bg/page.tsx index aead3082..0b304e6e 100644 --- a/app/(app)/books/bg/page.tsx +++ b/app/(app)/books/bg/page.tsx @@ -1,7 +1,7 @@ import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; -import { getBookMeta } from "@/lib/api"; +import { getBookMeta, getProseChapters } from "@/lib/api"; import { ogForBook } from "@/lib/og"; import { PageHeader } from "@/components/layout/page-header"; import { Card, CardContent } from "@/components/ui/card"; @@ -18,7 +18,10 @@ type ChapterInfo = { }; export default async function BgPage() { - const meta = await getBookMeta("bg"); + const [meta, introSegments] = await Promise.all([ + getBookMeta("bg"), + getProseChapters("bg", 0, "intro-segment"), + ]); if (!meta) notFound(); const intro = meta as unknown as { @@ -43,31 +46,66 @@ export default async function BgPage() {

{intro.author}

-
- - -
    - {intro.chapters.map((ch) => ( -
  • - -
    - - Chapter {ch.number} +
    + {/* Front Matter */} + {introSegments.length > 0 && ( +
    +

    + Front Matter +

    + + +
      + {introSegments.map((seg) => ( +
    • + +

      + {seg.title} +

      + +
    • + ))} +
    +
    +
    +
    + )} + + {/* Chapters */} +
    +

    + Chapters +

    + + +
      + {intro.chapters.map((ch) => ( +
    • + +
      + + Chapter {ch.number} + +

      + {ch.title} +

      +
      + + -

      {ch.title}

      -
    - - - - -
  • - ))} -
-
-
+ + + ))} + + + +
);