import React from "react"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getExportDocuments, formatScopeTitle, type ExportSortOption } from "@mcpedia/core"; import PdfExportView from "@/components/PdfExportView"; export const dynamic = "force-dynamic"; interface ExportPdfPageProps { searchParams: Promise<{ path?: string; section?: string; slug?: string; sort?: string; }>; } export async function generateMetadata({ searchParams }: ExportPdfPageProps) { const { path, section, slug } = await searchParams; const target = path || slug || section || "All Documents"; const title = formatScopeTitle(target); return { title: `Export PDF: ${title} — MCPedia`, description: `Export and print documentation and CTF writeups for ${title}`, }; } export default async function ExportPdfPage({ searchParams, }: ExportPdfPageProps) { const { path, section, slug, sort } = await searchParams; const targetPath = path || slug; const sortBy = (sort as ExportSortOption) || "category_points"; const exportData = await getExportDocuments({ path: targetPath, section: !targetPath ? section : undefined, sortBy, }); const backHref = targetPath ? `/${targetPath}` : section ? `/${section}` : "/"; if (exportData.documents.length === 0) { return (
Could not find any published documents matching the path{" "}
{targetPath || section || "root"}
.