71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import type { Metadata } from "next";
|
|
import Link from "next/link";
|
|
import { notFound } from "next/navigation";
|
|
import { getBookMeta } from "@/lib/api";
|
|
import { ogForBook } from "@/lib/og";
|
|
import { PageHeader } from "@/components/page-header";
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
type VolumeInfo = {
|
|
number: number;
|
|
totalChapters: number;
|
|
};
|
|
|
|
export function generateMetadata(): Metadata {
|
|
return ogForBook("kb");
|
|
}
|
|
|
|
export default async function KbPage() {
|
|
const meta = await getBookMeta("kb");
|
|
if (!meta) notFound();
|
|
|
|
const title = meta.title as string;
|
|
const author = meta.author as string;
|
|
const description = meta.description as string | undefined;
|
|
const volumes = meta.volumes as VolumeInfo[];
|
|
|
|
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">{title}</h1>
|
|
<p className="mt-1 text-muted-foreground">{author}</p>
|
|
</PageHeader>
|
|
<main className="max-w-5xl mx-auto px-6 py-8">
|
|
{description && (
|
|
<p className="text-muted-foreground mb-6">{description}</p>
|
|
)}
|
|
<Card className="divide-y divide-border">
|
|
<CardContent className="p-0">
|
|
<ul className="divide-y divide-border">
|
|
{volumes.map((vol) => (
|
|
<li key={vol.number}>
|
|
<Link
|
|
href={`/books/kb/${vol.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">
|
|
Volume {vol.number}
|
|
</Badge>
|
|
<p className="font-medium text-foreground">
|
|
{vol.totalChapters} chapters
|
|
</p>
|
|
</div>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</CardContent>
|
|
</Card>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|