import Link from "next/link"; import { notFound } from "next/navigation"; import { cookies } from "next/headers"; import { getDocument, getRelated, listRevisions } from "@mcpedia/core"; import { WEBHOOK_SECRET } from "@mcpedia/config"; import Markdown from "@/components/Markdown"; import DocForm from "@/components/DocForm"; import TOC from "@/components/TOC"; // Render at request time (content in Postgres, not available at build time). export const dynamic = "force-dynamic"; interface DocPageProps { params: Promise<{ section: string; slug: string[] }>; searchParams: Promise<{ edit?: string }>; } const SECTION_LABEL: Record = { docs: "Documentation", writeups: "Writeup", research: "Research", notes: "Note", }; const SECTION_ICON: Record = { docs: "๐Ÿ“„", writeups: "๐Ÿ“", research: "๐Ÿ”ฌ", notes: "๐Ÿ“Œ", }; export default async function DocPage({ params, searchParams }: DocPageProps) { const { section, slug } = await params; const { edit } = await searchParams; const fullSlug = `${section}/${slug.join("/")}`; const doc = await getDocument(fullSlug); if (!doc) notFound(); const cookieStore = await cookies(); const canEdit = cookieStore.get("mcpedia_admin")?.value != null; // Edit mode: inline form if (edit === "1" && canEdit) { return (
โ† Back to {doc.title}

Edit: {doc.title}

); } const related = await getRelated(fullSlug, 5); const revisions = await listRevisions(fullSlug, 10); return (
{/* Breadcrumb */} {/* Header */}
{SECTION_ICON[doc.section] || "๐Ÿ“„"} {SECTION_LABEL[doc.section] || doc.section}

{doc.title}

{doc.author || "unknown"} ยท {doc.tags.map((t) => ( #{t} ))}
{/* Content + TOC */}
{/* Related docs (card-style) */} {related.length > 0 && ( )} {/* History */} {revisions.length > 0 && ( )}
); }