export const dynamic = "force-dynamic"; import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getJournalMeta, slugToBookCode, type JournalChapterEntry, } from "@/lib/journals"; import { ogForJournal } from "@/lib/og"; import { PageHeader } from "@/components/layout/page-header"; import { Card, CardContent } from "@/components/ui/card"; export async function generateMetadata({ params, }: { params: Promise<{ slug: string }>; }): Promise { const { slug } = await params; const bookCode = slugToBookCode(slug); const meta = await getJournalMeta(bookCode); const title = meta?.title ?? slug; return ogForJournal(title); } export default async function JournalIndexPage({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const bookCode = slugToBookCode(slug); const meta = await getJournalMeta(bookCode); if (!meta) notFound(); return (
← Journals

{meta.title}

{meta.author}

{meta.description && (

{meta.description}

)} {meta.chapters.map((ch: JournalChapterEntry, idx: number) => { // Top-level chapter with a slug (Preface, Introduction, etc.) if ("slug" in ch && !("subChapters" in ch)) { return (

{ch.title}

); } // Group with sub-chapters (may be 2 or 3 levels deep) if ("subChapters" in ch) { const group = ch as { title: string; subChapters: { slug?: string; title: string; subChapters?: { slug: string; title: string }[]; }[]; }; return (

{group.title}

{group.subChapters.map((sc, scIdx) => { // Sub-chapter with its own nested sub-chapters (e.g., month → days) if ("subChapters" in sc && sc.subChapters) { return (

{sc.title}

    {sc.subChapters.map((day) => (
  • {day.title}

  • ))}
); } // Direct sub-chapter with a slug (e.g., Summary, Notice) if ("slug" in sc && sc.slug) { return (

{sc.title}

); } return null; })}
); } return null; })}
); }