// ─── PROJECTS ─────────────────────────────────────────────────────────────────
// Auto-collected from all window.PROJECT_* globals set by projects/*.jsx files.
// Display order is controlled by the `order` field on each project object.
//
// To add a project:
//   1. Create projects/your-slug.jsx (copy any existing one as a template)
//   2. Set an `order` field on the object (integer, lower = earlier)
//   3. Add a <script> tag for it in index.html (before data/projects.jsx)
//   — no changes needed here
// ─────────────────────────────────────────────────────────────────────────────
const _all = Object.keys(window)
  .filter((k) => k.startsWith("PROJECT_"))
  .map((k) => window[k])
  .sort((a, b) => (a.order ?? 999) - (b.order ?? 999));

const PROJECTS = _all
  .filter((p) => !p.hidden)
  .map((p, i) => ({ ...p, n: String(i + 1).padStart(2, "0") }));

// includes hidden projects — used by the router so hidden slugs still resolve
const ALL_PROJECTS = _all
  .map((p, i) => ({ ...p, n: String(i + 1).padStart(2, "0") }));

Object.assign(window, { PROJECTS, ALL_PROJECTS });
