import { allEntries, allLessons } from '$lib/language-learner/course'; import { COURSES, loadCourse } from '$lib/language-learner/courses'; import type { PageServerLoad } from './$types'; // Counted on the server so the overview doesn't download three full courses. export const load: PageServerLoad = async () => { const courses = await Promise.all(COURSES.map((c) => loadCourse(c.code))); return { counts: Object.fromEntries( courses.map((c) => [ c.code, { lessons: allLessons(c).length, words: allEntries(c).filter((e) => e.kind === 'word').length, levels: c.levels.map((lv) => lv.band) } ]) ) as Record }; };