import type { Metadata } from "next";
import Link from "next/link";
import { getBookMeta, getProseChapters } from "@/lib/api";
import { ogForBook } from "@/lib/og";
import { PageHeader } from "@/components/layout/page-header";
import { JsonLd } from "@/components/seo/json-ld";
import { bookJsonLd } from "@/lib/jsonld";
import { Card, CardContent } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { ExtractedVerseCount } from "../extracted-verse-count";
type ChapterInfo = {
number: number;
title: string;
totalVerses: number;
};
type LilaInfo = {
key: string;
name: string;
totalChapters: number;
totalVerses: number;
chapters: ChapterInfo[];
};
export function generateMetadata(): Metadata {
return ogForBook("cc");
}
export default async function CcPage() {
const [meta, introSegments] = await Promise.all([
getBookMeta("cc"),
getProseChapters("cc", 0, "intro-segment"),
]);
if (!meta) {
return (
Book metadata not found.
);
}
const lilas = meta.lilas as LilaInfo[];
const title = meta.title as string;
const author = meta.author as string;
return (
← Books
{title}
{author}
{introSegments.length > 0 && (
Front Matter
{introSegments.map((seg) => (
-
{seg.title}
))}
)}
{lilas.map((lila) => {
const totalVerses = lila.chapters.reduce(
(sum, ch) => sum + ch.totalVerses,
0,
);
return (
-
{lila.name}
{lila.totalChapters} chapters
);
})}
);
}