import { parseLesson, type ParsedLesson } from '@core/lesson-parse';

// Lessons are markdown files: drop a `.md` in lessons/ and it's picked up here —
// no registry to edit. Loaded raw at build (Vite glob) and parsed by the pure core
// parser into ordered blocks. The per-lesson HTML shells (one indexable URL each)
// are generated from the same files in scripts/learn-pages.ts; both read the lesson
// frontmatter, so the routes and the rendered set stay in agreement.
const SOURCES = import.meta.glob<string>('./lessons/*.md', {
  query: '?raw',
  import: 'default',
  eager: true,
});

/** Every parsed lesson, ordered by file path (stable, matches the route generator). */
export const LESSONS: ParsedLesson[] = Object.entries(SOURCES)
  .sort(([a], [b]) => a.localeCompare(b))
  .map(([, source]) => parseLesson(source));
