revert: gh workflow/validation - already covered by building

This commit is contained in:
Lewis Wynne 2026-03-27 21:37:59 +00:00
parent 66360b9c7a
commit f2acf36784
4 changed files with 2 additions and 72 deletions

View file

@ -5,8 +5,7 @@
"dev": "astro dev --port 4322",
"build": "astro build --remote && node scripts/generate-stats.js",
"preview": "astro preview",
"serve": "pnpm build && npx serve .vercel/output/static -l 4322",
"validate": "node scripts/validate-content.js"
"serve": "pnpm build && npx serve .vercel/output/static -l 4322"
},
"dependencies": {
"@astrojs/db": "^0.19.0",

View file

@ -1,43 +0,0 @@
import fs from 'node:fs';
import path from 'node:path';
import yaml from 'js-yaml';
const root = path.resolve(import.meta.dirname, '..');
const contentDir = path.join(root, 'content');
const publicDir = path.join(root, 'public');
const errors = [];
const mdFiles = fs.readdirSync(contentDir).filter(f => f.endsWith('.md'));
for (const file of mdFiles) {
const content = fs.readFileSync(path.join(contentDir, file), 'utf8');
const match = content.match(/^---\n([\s\S]*?)\n---/);
if (!match) {
errors.push(`${file}: missing frontmatter`);
continue;
}
const frontmatter = match[1];
if (!/^date:\s*.+/m.test(frontmatter)) {
errors.push(`${file}: missing required 'date' field`);
}
}
const configPath = path.join(publicDir, 'config.yaml');
const config = fs.existsSync(configPath)
? yaml.load(fs.readFileSync(configPath, 'utf8'))
: {};
const configDates = config.dates || {};
const txtFiles = fs.readdirSync(publicDir).filter(f => f.endsWith('.txt'));
for (const file of txtFiles) {
if (!configDates[file]) {
errors.push(`${file}: missing date in config.yaml`);
}
}
if (errors.length) {
console.error('Content validation failed:\n');
for (const err of errors) console.error(` - ${err}`);
console.error('');
process.exit(1);
} else {
console.log(`Validated ${mdFiles.length} posts and ${txtFiles.length} txt files.`);
}