// Checks lesson MDX files compile and follow the basic rules in docs/LESSONS.md. // Usage: node scripts/check-lessons.mjs [dir] (default content/lessons) import fs from "fs"; import path from "path"; import matter from "gray-matter"; import { compile } from "@mdx-js/mdx"; import remarkGfm from "remark-gfm"; const root = process.argv[2] || "content/lessons"; const files = []; (function walk(dir) { for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { const full = path.join(dir, entry.name); if (entry.isDirectory()) walk(full); else if (entry.name.endsWith(".mdx")) files.push(full); } })(root); let failed = 0; for (const file of files) { const problems = []; const raw = fs.readFileSync(file, "utf8"); const { data, content } = matter(raw); for (const key of ["title", "description", "updated", "minutes"]) if (!data[key]) problems.push(`missing ${key}`); const shown = `${data.title} ${data.description} ${content}`; if (/\b(business|businesses|branch|branches)\b/i.test(shown)) problems.push('uses the word "business" or "branch"'); if (raw.includes("—")) problems.push("has an em dash"); if (/youtube|