Clear all blockers: payment tested, CI/CD secrets added, status launch-ready

This commit is contained in:
Hoid 2026-02-16 18:49:39 +00:00
parent 33b1489e6c
commit 0ab4afd398
94 changed files with 10014 additions and 931 deletions

View file

@ -0,0 +1,70 @@
#!/usr/bin/env node
/**
* Build-time HTML templating system for DocFast.
* No dependencies uses only Node.js built-ins.
*
* - 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)
* - Writes output to public/
*/
import { readFileSync, writeFileSync, readdirSync, mkdirSync } from 'node:fs';
import { join, basename } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const ROOT = join(__dirname, '..');
const PAGES_DIR = join(ROOT, 'templates', 'pages');
const PARTIALS_DIR = join(ROOT, 'templates', 'partials');
const OUTPUT_DIR = join(ROOT, 'public');
// Load all partials
const partials = {};
for (const file of readdirSync(PARTIALS_DIR)) {
if (!file.endsWith('.html')) continue;
const name = file.replace('.html', '');
partials[name] = readFileSync(join(PARTIALS_DIR, file), 'utf-8');
}
console.log(`Loaded ${Object.keys(partials).length} partials: ${Object.keys(partials).join(', ')}`);
// Process each page
const pages = readdirSync(PAGES_DIR).filter(f => f.endsWith('.html'));
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?/, '');
}
// Replace {{> partial_name}} with partial content (support nested partials)
let maxDepth = 5;
while (maxDepth-- > 0 && content.includes('{{>')) {
content = content.replace(/\{\{>\s*([a-zA-Z0-9_-]+)\s*\}\}/g, (match, name) => {
if (!(name in partials)) {
console.warn(` Warning: partial "${name}" not found in ${file}`);
return match;
}
return partials[name];
});
}
// Replace {{title}} variable
content = content.replace(/\{\{title\}\}/g, title);
// Write output
const outPath = join(OUTPUT_DIR, file);
writeFileSync(outPath, content);
console.log(`${file} (${(content.length / 1024).toFixed(1)}KB)`);
}
console.log('Done!');