Build static Astro pilot for Happy Tails

This commit is contained in:
Kevin
2026-09-02 00:54:33 -04:00
parent cfe0a7d98d
commit 56a80951b7
42 changed files with 7171 additions and 134 deletions
+17
View File
@@ -0,0 +1,17 @@
import { access, readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
const key = process.env.SITE_KEY;
if (!key) throw new Error('SITE_KEY is required.');
const root = resolve(`dist/${key}`);
const required = ['index.html', '404.html'];
if (key === 'www') required.push('about/index.html', 'services/index.html', 'contact/index.html');
for (const file of required) await access(resolve(root, file));
const pages = await Promise.all(required.filter((file) => file.endsWith('.html')).map(async (file) => ({ file, html: await readFile(resolve(root, file), 'utf8') })));
for (const { file, html } of pages) {
if (html.includes('{{') || html.includes('{%')) throw new Error(`${file} contains an unresolved template placeholder.`);
if (!/<title>[^<]+<\/title>/.test(html)) throw new Error(`${file} is missing a title.`);
for (const match of html.matchAll(/(?:src|href)="(\/images\/[^"?#]+)"/g)) await access(resolve(root, `.${match[1]}`));
}
console.log(`Verified ${key}: ${required.join(', ')}`);