import { exportCase } from "@/lib/research/boards"; import { exportFileName } from "@/lib/research/board.mjs"; import { fail } from "../../../_respond"; export const dynamic = "force-dynamic"; // The board as cited markdown in the house format (lib/research/board.mjs // exportMarkdown): `# title`, the summary, a `##` per section, one finding per // quote -- claim, "quote" — [title @ m:ss](link) -- and `## Coverage`. It // converts as a /sweep report. `?download=1` names it as a file. export async function GET(request: Request, ctx: { params: Promise<{ id: string }> }) { try { const { id } = await ctx.params; const { doc, markdown } = await exportCase(id); const download = new URL(request.url).searchParams.get("download") === "1"; return new Response(markdown, { headers: { "content-type": "text/markdown; charset=utf-8", "cache-control": "no-store", ...(download ? { "content-disposition": `attachment; filename="${exportFileName(doc)}"` } : {}), }, }); } catch (e) { return fail(e); } }