#!/usr/bin/env node import { mkdirSync, writeFileSync } from "node:fs"; import { dirname } from "node:path"; const TEMPLATES = { minimal: `--- title: "{title}" author: "{author}" theme: name: {theme} --- First Slide === Your content here. Second Slide === More content. `, "tech-talk": `--- title: "{title}" author: "{author}" theme: name: {theme} --- Why This Matters === [Establish motivation in 2-3 sentences] The Problem === [Describe the pain point] * Point 1 * Point 2 * Point 3 The Solution === [Your approach] Demo === [Live code or screenshots] Summary === [Key takeaways] **Questions?** `, }; const VALID_THEMES = [ "catppuccin-latte", "catppuccin-frappe", "catppuccin-macchiato", "catppuccin-mocha", "dark", "gruvbox-dark", "light", "terminal-dark", "terminal-light", "tokyonight-day", "tokyonight-moon", "tokyonight-night", "tokyonight-storm", ]; function arg(name, def) { const i = process.argv.indexOf(name); return i === -1 ? def : process.argv[i + 1]; } function has(name) { return process.argv.includes(name); } function main() { if (has("--list-themes")) { console.log("Available themes:"); for (const t of VALID_THEMES) console.log(` ${t}`); return 0; } const title = arg("--title"), author = arg("--author"), theme = arg("--theme", "dark"), template = arg("--template", "minimal"), output = arg("--output", "-"); if (!title || !author) { console.error("Error: --title and --author are required"); return 1; } if (!VALID_THEMES.includes(theme)) { console.error(`Error: Unknown theme '${theme}'`); console.error("Use --list-themes to see available themes."); return 1; } if (!TEMPLATES[template]) { console.error(`Error: Unknown template '${template}'`); return 1; } const content = TEMPLATES[template] .replaceAll("{title}", title) .replaceAll("{author}", author) .replaceAll("{theme}", theme); if (output === "-") console.log(content); else { mkdirSync(dirname(output), { recursive: true }); writeFileSync(output, content, "utf8"); console.log(`Created: ${output}`); } return 0; } process.exit(main());