feat: add cc front matter

This commit is contained in:
gosangam
2026-06-14 13:57:38 +05:30
parent a4baf6d215
commit 45c7cf047e
2 changed files with 84 additions and 10 deletions
+32 -3
View File
@@ -1,6 +1,6 @@
import type { Metadata } from "next";
import Link from "next/link";
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";
@@ -26,7 +26,10 @@ export function generateMetadata(): Metadata {
}
export default async function CcPage() {
const meta = await getBookMeta("cc");
const [meta, introSegments] = await Promise.all([
getBookMeta("cc"),
getProseChapters("cc", 0, "intro-segment"),
]);
if (!meta) {
return (
<div className="p-8 text-center text-muted-foreground">
@@ -51,7 +54,33 @@ export default async function CcPage() {
<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">
<main className="max-w-5xl mx-auto px-6 py-8 space-y-8">
{introSegments.length > 0 && (
<div>
<h2 className="text-sm font-bold uppercase tracking-wider text-muted-foreground mb-3">
Front Matter
</h2>
<Card className="divide-y divide-border py-0">
<CardContent className="p-0">
<ul className="divide-y divide-border">
{introSegments.map((seg) => (
<li key={seg.slug}>
<Link
href={`/books/cc/${seg.slug}`}
className="flex px-5 py-4 hover:bg-muted transition-colors"
>
<p className="font-medium text-foreground">
{seg.title}
</p>
</Link>
</li>
))}
</ul>
</CardContent>
</Card>
</div>
)}
<Card className="divide-y divide-border">
<CardContent className="p-0">
<ul className="divide-y divide-border">