Branchwell

Become a Pro / website · becomeapro.ai / src / lib / lesson-types.ts

Raw 925 B on 807b8657974875ed44f307014cfbf8ce673dc5a6
1// Client-safe lesson types (lib/lessons.ts reads the filesystem)
2export type Level = "Beginner" | "Intermediate" | "Advanced";
3
4export type LessonMeta = {
5 area: string;
6 field: string;
7 slug: string;
8 title: string;
9 description: string;
10 level: Level;
11 minutes: number;
12 // The day the lesson was last checked or revised (front matter `updated`)
13 updated: string;
14 order: number;
15};
16
17export function lessonPath(l: Pick<LessonMeta, "area" | "field" | "slug">): string {
18 return `/${l.area}/${l.field}/${l.slug}`;
19}
20
21// Saved lessons are stored in the database by this key (field slugs are unique across the site)
22export function lessonKey(l: Pick<LessonMeta, "field" | "slug">): string {
23 return `${l.field}/${l.slug}`;
24}
25
26export function formatDate(iso: string): string {
27 return new Date(`${iso}T12:00:00Z`).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", timeZone: "UTC" });
28}