#!/usr/bin/env node /** * Generate output HTML from template for space-coloring documents. * * Usage: node generate.mjs * Example: node generate.mjs space-coloring-1 * * Coloring pages have no editable data layer — the template IS the output. * If a data.json exists in the future, it's currently ignored. */ import { readFileSync, writeFileSync, existsSync } from 'fs'; import { join, dirname } from 'path'; import { fileURLToPath } from 'url'; import { postGenerate } from '../../../src/scripts/post-generate.mjs'; const __dirname = dirname(fileURLToPath(import.meta.url)); const docsDir = join(__dirname, '..', 'docs'); const docId = process.argv[2]; if (!docId) { console.error('Usage: node generate.mjs '); process.exit(1); } const templatePath = join(docsDir, `${docId}.template.html`); const outputPath = join(docsDir, `${docId}.output.html`); if (!existsSync(templatePath)) { console.error(`Template not found: ${templatePath}`); process.exit(1); } const html = readFileSync(templatePath, 'utf-8'); writeFileSync(outputPath, html); console.log(`Generated: ${outputPath}`); await postGenerate(outputPath);