Something went wrong. Try again.
slides from July atproto.la meetup talk on an atmospheric cms
Something went wrong. Try again.
1.1 kB · 31 lines
JavaScript
at main
1234567891011121314151617181920212223242526272829303132// pnpm new <slug> ["Talk title"] — copies template/ into talks/<slug>import { cpSync, existsSync, readFileSync, writeFileSync } from "node:fs";import { join } from "node:path";import { talksDir, templateDir } from "./lib.mjs";
const [slug, ...titleWords] = process.argv.slice(2);if (!slug || !/^[a-z0-9][a-z0-9-]*$/.test(slug)) { console.error('Usage: pnpm new <slug> ["Talk title"] (slug: lowercase letters, numbers, dashes)'); process.exit(1);}
const dir = join(talksDir, slug);if (existsSync(dir)) { console.error(`talks/${slug} already exists.`); process.exit(1);}
const title = titleWords.join(" ") || slug.replaceAll("-", " ").replace(/^./, (c) => c.toUpperCase());const date = new Date().toISOString().slice(0, 10);
cpSync(templateDir, dir, { recursive: true });const entry = join(dir, "slides.md");writeFileSync( entry, readFileSync(entry, "utf8") .replaceAll("{{titleYaml}}", JSON.stringify(title)) .replaceAll("{{title}}", title.replaceAll("&", "&").replaceAll("<", "<")) .replaceAll("{{date}}", date),);
console.log(`Created talks/${slug}\n pnpm dev ${slug}`);