import 'dotenv/config'; import { mkdir } from 'node:fs/promises'; import path from 'node:path'; import { loadProjectConfig } from "./lib/config.js"; import { resolveDeck } from "./lib/content.js"; import { runSlidev } from "./lib/run-slidev.js"; import { resolveTheme } from "./lib/theme.js"; const args = process.argv.slice(2); const slug = args.find(argument => !argument.startsWith('-')); const formatIndex = args.indexOf('--format'); const format = formatIndex >= 0 ? args[formatIndex + 1] : 'pdf'; const allowed = new Set(['pdf', 'png', 'pptx', 'md']); if (!allowed.has(format)) throw new Error(`不支持导出格式:${format}`); const config = await loadProjectConfig(); const deck = await resolveDeck(slug, process.cwd(), config.slidesDir); const exportDir = path.join(process.cwd(), config.exportDir); await mkdir(exportDir, { recursive: true }); const output = path.join(exportDir, `${deck.slug}.${format}`); const slidevArgs = [ 'export', deck.entry, '--theme', resolveTheme(config.theme), '--format', format, '--output', output, ]; // Slidev's one-piece exporter may capture off-screen lazy images before they // are painted. Per-slide export renders each canvas as the active slide and is // reliable for Markdown images across PNG, PDF, and screenshot-based PPTX. if (format !== 'md') slidevArgs.push('--per-slide'); await runSlidev(slidevArgs); console.log(`导出完成:${path.relative(process.cwd(), output)}`); //# sourceMappingURL=export.js.map