const fs = require('node:fs');
const path = require('node:path');
const { execSync } = require('node:child_process');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
const APPS_DIR = path.join(SRC_DIR, 'apps');
// Standard Navigation Template
// Note: We use absolute paths (/) so they work from any depth, assuming Cloudflare Pages root.
const NAV_TEMPLATE = `
`;
function cleanDist() {
if (fs.existsSync(DIST_DIR)) {
fs.rmSync(DIST_DIR, { recursive: true, force: true });
}
fs.mkdirSync(DIST_DIR);
}
function processHtml(filePath, outPath) {
let content = fs.readFileSync(filePath, 'utf-8');
// Simple regex-based injection.
// 1. Remove existing (if any) to avoid duplication.
// 2. Inject new NAV_TEMPLATE at the start of
.
// Remove existing nav
content = content.replace(/