repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
pi/agent/skills/presenterm/scripts/new-presentation.mjs
Raw#!/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.
<!-- end_slide -->
Second Slide
===
More content.
<!-- end_slide -->
`,
"tech-talk": `---
title: "{title}"
author: "{author}"
theme:
name: {theme}
---
<!-- speaker_note: THE BIG WHY - hook the audience immediately -->
Why This Matters
===
[Establish motivation in 2-3 sentences]
<!-- end_slide -->
The Problem
===
[Describe the pain point]
<!-- incremental_lists: true -->
* Point 1
* Point 2
* Point 3
<!-- incremental_lists: false -->
<!-- end_slide -->
The Solution
===
[Your approach]
<!-- end_slide -->
<!-- jump_to_middle -->
Demo
===
[Live code or screenshots]
<!-- end_slide -->
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());