Files
scrollsmith/index.js
Keli Grubb ed95dd08a2
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
initial commit
2025-08-29 22:56:40 -04:00

32 lines
1003 B
JavaScript

import 'dotenv/config';
import { generateDungeonPDF } from "./generateDungeon.js";
import { generateDungeon } from "./dungeonGenerator.js";
// Utility to create a filesystem-safe filename from the dungeon title
function slugify(text) {
return text
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-') // replace non-alphanumeric with hyphens
.replace(/^-+|-+$/g, ''); // trim leading/trailing hyphens
}
(async () => {
try {
// Generate dungeon JSON from Ollama
const dungeonData = await generateDungeon();
// Optional: replace the map placeholder with your local map path
// dungeonData.map = "/absolute/path/to/dungeon-map.png";
// Generate a safe filename based on the dungeon's title
const filename = `${slugify(dungeonData.title)}.pdf`;
// Generate PDF
await generateDungeonPDF(dungeonData, filename);
console.log(`Dungeon PDF successfully generated: ${filename}`);
} catch (err) {
console.error("Error generating dungeon:", err);
}
})();