export type ExportFormat = 'pdf' | 'pptx' | 'html' /** POST the current markdown to the server, then download the rendered file. */ export async function requestExport(markdown: string, format: ExportFormat): Promise { const res = await fetch('/api/export', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ markdown, format }), }) if (!res.ok) { let message = 'Export failed' try { const j = await res.json() message = j.detail || j.error || message } catch { /* ignore */ } throw new Error(message) } const blob = await res.blob() const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = `deck.${format}` document.body.appendChild(a) a.click() a.remove() URL.revokeObjectURL(url) }