89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import Link from "next/link";
|
|
import { PageHeader } from "@/components/page-header";
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { ExtractedVerseCount } from "../extracted-verse-count";
|
|
import { getBookMeta } from "@/lib/api";
|
|
import { notFound } from "next/navigation";
|
|
|
|
type ChapterInfo = {
|
|
number: number;
|
|
title: string;
|
|
totalVerses: number;
|
|
};
|
|
|
|
type CantoInfo = {
|
|
number: number;
|
|
title: string;
|
|
totalChapters: number;
|
|
chapters: ChapterInfo[];
|
|
};
|
|
|
|
export default async function SbPage() {
|
|
const meta = await getBookMeta("sb");
|
|
if (!meta) notFound();
|
|
|
|
const intro = meta as {
|
|
book: string;
|
|
title: string;
|
|
author: string;
|
|
totalCantos: number;
|
|
cantos: CantoInfo[];
|
|
};
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background">
|
|
<PageHeader>
|
|
<Link
|
|
href="/books"
|
|
className="text-sm text-muted-foreground hover:text-foreground"
|
|
>
|
|
← Books
|
|
</Link>
|
|
<h1 className="mt-3 text-3xl font-bold text-foreground">
|
|
{intro.title}
|
|
</h1>
|
|
<p className="mt-1 text-muted-foreground">{intro.author}</p>
|
|
</PageHeader>
|
|
<main className="max-w-3xl mx-auto px-6 py-8">
|
|
<Card className="divide-y divide-border">
|
|
<CardContent className="p-0">
|
|
<ul className="divide-y divide-border">
|
|
{intro.cantos.map((canto) => {
|
|
const totalVerses = canto.chapters.reduce(
|
|
(sum, ch) => sum + ch.totalVerses,
|
|
0,
|
|
);
|
|
return (
|
|
<li key={canto.number}>
|
|
<Link
|
|
href={`/books/sb/${canto.number}`}
|
|
className="flex flex-col sm:flex-row sm:items-center sm:justify-between px-5 py-4 gap-1 sm:gap-0 hover:bg-muted transition-colors"
|
|
>
|
|
<div>
|
|
<Badge variant="secondary" className="mb-1">
|
|
Canto {canto.number}
|
|
</Badge>
|
|
<p className="font-medium text-foreground">
|
|
{canto.title}
|
|
</p>
|
|
</div>
|
|
<span className="text-sm text-muted-foreground sm:shrink-0 sm:ml-4">
|
|
{canto.totalChapters} chapters ·{" "}
|
|
<ExtractedVerseCount
|
|
count={totalVerses}
|
|
label="extracted verses"
|
|
/>
|
|
</span>
|
|
</Link>
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</CardContent>
|
|
</Card>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|