#!/usr/bin/env node /** * Post-build: copy 410.html to each 410-Gone URL path as index.html. * So static preview (serve dist) shows the 410 page at those URLs. * nginx still returns 410 for these paths via explicit location blocks. */ import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const DIST = path.join(__dirname, '..', 'dist'); const SOURCE = path.join(DIST, '410.html'); const PATHS = [ '2024/02/18/hello-world', 'pt', 'feed', 'category/uncategorized/feed', 'category/uncategorized', 'comments/feed', ]; function main() { if (!fs.existsSync(SOURCE)) { console.error('dist/410.html not found. Run build first.'); process.exit(1); } const content = fs.readFileSync(SOURCE, 'utf8'); for (const dir of PATHS) { const dirPath = path.join(DIST, dir); fs.mkdirSync(dirPath, { recursive: true }); fs.writeFileSync(path.join(dirPath, 'index.html'), content, 'utf8'); } console.log('✓ 410 page copied to', PATHS.length, 'paths for preview.'); } main();