export const dynamic = "force-dynamic"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getMagazineContent, getMagazineMeta, getMagazineSidebarItems, slugToBookCode, type MagazineSidebarItem, } from "@/lib/magazines"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav"; export default async function MagazineIssuePage({ params, }: { params: Promise<{ slug: string; issue: string }>; }) { const { slug, issue: issueSlug } = await params; const bookCode = slugToBookCode(slug); const [meta, content, sidebarItems] = await Promise.all([ getMagazineMeta(bookCode), getMagazineContent(bookCode, issueSlug), getMagazineSidebarItems(bookCode), ]); if (!meta || !content) notFound(); const navItems = sidebarItems.filter((item) => item.type !== "heading"); const currentIdx = navItems.findIndex((item) => item.slug === issueSlug); const prev = currentIdx > 0 ? navItems[currentIdx - 1] : null; const next = currentIdx < navItems.length - 1 ? navItems[currentIdx + 1] : null; return (
← {meta.title}

{content.title}

{content.paragraphs.map((paragraph, i) => (
))}
); } function IssueSidebar({ items, currentSlug, magSlug, }: { items: MagazineSidebarItem[]; currentSlug: string; magSlug: string; }) { return ( ); } function IssueNav({ prev, next, navItems, currentSlug, magSlug, magTitle, showMobileNav = false, }: { prev: MagazineSidebarItem | null; next: MagazineSidebarItem | null; navItems: MagazineSidebarItem[]; currentSlug: string; magSlug: string; magTitle: string; showMobileNav?: boolean; }) { const mobileNavGroups: MobileNavGroup[] = []; if (showMobileNav && navItems.length > 0) { mobileNavGroups.push({ title: "Issues", items: navItems.map((i) => ({ slug: i.slug, label: i.label, href: `/magazines/${magSlug}/${i.slug}`, type: i.type, })), }); } return (
{showMobileNav && ( )} {prev ? ( {prev.label} Previous ) : (
)}
{next ? ( {next.label} Next ) : (
)}
); }