/** * Structured Data Validation Script * * Validates JSON-LD structured data in built HTML files * Run: node .agents/seo-specialist/validate-structured-data.js */ import { readFileSync, readdirSync, statSync } from 'fs'; import { join, extname } from 'path'; const distDir = './dist'; const errors = []; const warnings = []; const schemaStats = {}; // ANSI color codes for terminal output const colors = { reset: '\x1b[0m', green: '\x1b[32m', yellow: '\x1b[33m', red: '\x1b[31m', cyan: '\x1b[36m', bold: '\x1b[1m' }; function log(message, color = 'reset') { console.log(`${colors[color]}${message}${colors.reset}`); } /** * Recursively find all HTML files in dist directory */ function findHtmlFiles(dir) { const files = []; try { const items = readdirSync(dir); for (const item of items) { const fullPath = join(dir, item); const stat = statSync(fullPath); if (stat.isDirectory()) { files.push(...findHtmlFiles(fullPath)); } else if (extname(item) === '.html') { files.push(fullPath); } } } catch (err) { errors.push(`Error reading directory ${dir}: ${err.message}`); } return files; } /** * Extract and validate JSON-LD schemas from HTML content */ function extractSchemas(html, filePath) { const schemaRegex = /