BUG-049: No invoice for Pro customers

This commit is contained in:
Hoid 2026-02-16 18:52:01 +00:00
parent 0ab4afd398
commit 0abd81f024
13 changed files with 139 additions and 212 deletions

View file

@ -6,12 +6,13 @@
* - Reads page sources from templates/pages/*.html
* - Reads partials from templates/partials/*.html
* - Replaces {{> partial_name}} with partial content
* - Supports {{title}} variable (set via <!-- title: Page Title --> comment at top)
* - Supports <!-- key: value --> metadata comments at top of page files
* - Replaces {{key}} variables with extracted metadata
* - Writes output to public/
*/
import { readFileSync, writeFileSync, readdirSync, mkdirSync } from 'node:fs';
import { join, basename } from 'node:path';
import { readFileSync, writeFileSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
@ -37,13 +38,13 @@ console.log(`Processing ${pages.length} pages...`);
for (const file of pages) {
let content = readFileSync(join(PAGES_DIR, file), 'utf-8');
// Extract title from <!-- title: ... --> comment
let title = '';
const titleMatch = content.match(/^<!--\s*title:\s*(.+?)\s*-->/);
if (titleMatch) {
title = titleMatch[1];
// Remove the title comment from output
content = content.replace(/^<!--\s*title:.+?-->\n?/, '');
// Extract all <!-- key: value --> metadata comments from the top
const vars = {};
while (true) {
const m = content.match(/^<!--\s*([a-zA-Z_-]+):\s*(.+?)\s*-->\n?/);
if (!m) break;
vars[m[1]] = m[2];
content = content.slice(m[0].length);
}
// Replace {{> partial_name}} with partial content (support nested partials)
@ -58,8 +59,12 @@ for (const file of pages) {
});
}
// Replace {{title}} variable
content = content.replace(/\{\{title\}\}/g, title);
// Replace {{variable}} with extracted metadata
content = content.replace(/\{\{([a-zA-Z_-]+)\}\}/g, (match, key) => {
if (key in vars) return vars[key];
console.warn(` Warning: variable "${key}" not defined in ${file}`);
return match;
});
// Write output
const outPath = join(OUTPUT_DIR, file);