This commit is contained in:
31
index.js
Normal file
31
index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user