/** * Static page builder for Tischlerei Staffenberger. * Expands markers in templates/*.html * with the referenced partial's contents and writes the result to the * project root (index.html, pictures.html, shop.html, impressum.html). * * Run: node scripts/build.js */ 'use strict'; const fs = require('fs'); const path = require('path'); const PROJECT_ROOT = path.join(__dirname, '..'); const TEMPLATES_DIR = path.join(PROJECT_ROOT, 'templates'); const INCLUDE_RE = /[ \t]*/g; function expandIncludes(content) { return content.replace(INCLUDE_RE, (match, includePath) => { const partialPath = path.join(PROJECT_ROOT, includePath); return fs.readFileSync(partialPath, 'utf8').replace(/\n$/, ''); }); } function main() { const pages = fs.readdirSync(TEMPLATES_DIR).filter(f => f.endsWith('.html')); for (const page of pages) { const templatePath = path.join(TEMPLATES_DIR, page); const outputPath = path.join(PROJECT_ROOT, page); const content = expandIncludes(fs.readFileSync(templatePath, 'utf8')); fs.writeFileSync(outputPath, content); console.log(`built ${page}`); } } main();