diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml deleted file mode 100644 index 3535d88..0000000 --- a/.github/workflows/validate.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Validate content -on: - push: - paths: - - 'www/content/**' - - 'www/public/*.txt' - - 'www/public/config.yaml' - pull_request: - paths: - - 'www/content/**' - - 'www/public/*.txt' - - 'www/public/config.yaml' - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: pnpm - - run: pnpm install --frozen-lockfile - - run: pnpm validate:www diff --git a/package.json b/package.json index c870fd5..6ebe20f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "dev:penfield": "pnpm --filter @ily/penfield dev", "dev:www": "pnpm --filter @ily/www dev", "build:penfield": "pnpm --filter @ily/penfield build", - "build:www": "pnpm --filter @ily/www build", - "validate:www": "pnpm --filter @ily/www validate" + "build:www": "pnpm --filter @ily/www build" } } diff --git a/www/package.json b/www/package.json index 5c7ad4d..cfa3cc7 100644 --- a/www/package.json +++ b/www/package.json @@ -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", diff --git a/www/scripts/validate-content.js b/www/scripts/validate-content.js deleted file mode 100644 index 3cce1f2..0000000 --- a/www/scripts/validate-content.js +++ /dev/null @@ -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.`); -}