export const dynamic = "force-dynamic";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
getMagazineMeta,
slugToBookCode,
type MagazineChapterEntry,
} from "@/lib/magazines";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
export default async function MagazineIndexPage({
params,
}: {
params: Promise<{ slug: string }>;
}) {
const { slug } = await params;
const bookCode = slugToBookCode(slug);
const meta = await getMagazineMeta(bookCode);
if (!meta) notFound();
return (
← Magazines
{meta.title}
{meta.author}
{meta.description && (
{meta.description}
)}
{meta.chapters.map((ch: MagazineChapterEntry, idx: number) => {
if ("slug" in ch && !("subChapters" in ch)) {
return (
{ch.title}
);
}
if ("subChapters" in ch) {
const group = ch as {
title: string;
subChapters: { slug: string; title: string }[];
};
return (
{group.title}
{group.subChapters.map((sc) => (
-
{sc.title}
))}
);
}
return null;
})}
);
}