Dumb hardcoding

This commit is contained in:
Knight 2024-12-28 11:01:47 -05:00
parent d575fd58e2
commit 81daaa174a
3 changed files with 52 additions and 41 deletions

View File

@ -5,7 +5,7 @@ services:
build: . build: .
volumes: volumes:
- ./images:/app/images - ./images:/app/images
- ./images.json:/app/images.json - /var/core/analogGallery/images.json:/app/images.json
expose: expose:
- "3000" - "3000"
environment: environment:

View File

@ -7,6 +7,10 @@ import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
async function generateSite() { async function generateSite() {
try {
// Check if images.json exists before trying to read it
await fs.access('images.json', fs.constants.F_OK);
// Read the images data // Read the images data
const imagesData = JSON.parse( const imagesData = JSON.parse(
await fs.readFile('images.json', 'utf-8') await fs.readFile('images.json', 'utf-8')
@ -116,6 +120,14 @@ async function generateSite() {
await fs.writeFile('public/index.html', indexHtml); await fs.writeFile('public/index.html', indexHtml);
console.log('Site generated successfully!'); console.log('Site generated successfully!');
} catch (error) {
if (error.code === 'ENOENT') {
console.error('images.json does not exist. Please run fetchImages.js first.');
} else {
console.error('Error generating site:', error);
}
throw error;
}
} }
async function serveStaticSite(port = 3000) { async function serveStaticSite(port = 3000) {

View File

@ -1,3 +1,2 @@
#!/bin/sh #!/bin/bash
node generateSite.js & # Run the site generator in background node fetchImages.js && node generateSite.js
node fetchImages.js # Run the image fetcher in foreground