#!/usr/bin/env node /** * Post-build prerender shells for money/SEO pages (crawlable HTML + meta). * Usage: node scripts/prerender-money-pages.mjs [--dist=dist] */ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' const __dirname = dirname(fileURLToPath(import.meta.url)) const repoRoot = join(__dirname, '..') const distArg = process.argv.find((a) => a.startsWith('--dist=')) const distDir = distArg ? distArg.split('=')[1] : join(repoRoot, 'dist') const PAGES = [ { path: 'donate', title: 'Donate | Miracles in Motion Foundation', description: 'Give with confidence to Miracles in Motion Foundation. Secure online donations support outreach and emergency assistance in Los Angeles County.', h1: 'Donate', lead: 'Your gift restores hope through outreach, emergency assistance, and compassionate care.', }, { path: 'request-assistance', title: 'Request Assistance | Miracles in Motion Foundation', description: 'Request non-emergency assistance from Miracles in Motion Foundation. We respond within 24–48 hours. For urgent needs call (818) 491-6884.', h1: 'Request Assistance', lead: 'Compassionate support for individuals and families in crisis throughout Los Angeles County.', }, { path: 'about', title: 'About Us | Miracles in Motion Foundation', description: 'Miracles in Motion Foundation is a California nonprofit serving Los Angeles County with faith, hope, and community restoration.', h1: 'About Miracles in Motion', lead: 'Faith • Hope • Community • Restoration', }, ] const indexPath = join(distDir, 'index.html') let shell try { shell = readFileSync(indexPath, 'utf8') } catch { console.error(`prerender: missing ${indexPath} — run vite build first`) process.exit(1) } for (const page of PAGES) { const dir = join(distDir, page.path) mkdirSync(dir, { recursive: true }) const noscript = `` let html = shell .replace(/