69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
import Link from "next/link";
|
|
import { PageHeader } from "@/components/page-header";
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
import { ExtractedVerseCount } from "../extracted-verse-count";
|
|
|
|
type ChapterInfo = {
|
|
number: number;
|
|
title: string;
|
|
totalVerses: number;
|
|
};
|
|
|
|
type Intro = {
|
|
book: string;
|
|
title: string;
|
|
author: string;
|
|
totalChapters: number;
|
|
chapters: ChapterInfo[];
|
|
};
|
|
|
|
export default function BgPage() {
|
|
const introPath = path.join(process.cwd(), "app/lib/books/bg/intro.json");
|
|
const intro: Intro = JSON.parse(fs.readFileSync(introPath, "utf-8"));
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background">
|
|
<PageHeader>
|
|
<Link
|
|
href="/books"
|
|
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
>
|
|
← 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 py-0">
|
|
<CardContent className="p-0">
|
|
<ul className="divide-y divide-border">
|
|
{intro.chapters.map((ch) => (
|
|
<li key={ch.number}>
|
|
<Link
|
|
href={`/books/bg/${ch.number}`}
|
|
className="flex items-center justify-between px-5 py-4 hover:bg-muted transition-colors"
|
|
>
|
|
<div>
|
|
<span className="text-sm text-primary font-medium">
|
|
Chapter {ch.number}
|
|
</span>
|
|
<p className="font-medium text-foreground">{ch.title}</p>
|
|
</div>
|
|
<span className="text-sm text-muted-foreground shrink-0 ml-4">
|
|
<ExtractedVerseCount count={ch.totalVerses} />
|
|
</span>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</CardContent>
|
|
</Card>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|