Become a Pro / website · becomeapro.ai / src / lib / lesson-types.ts
| 1 | // Client-safe lesson types (lib/lessons.ts reads the filesystem) |
| 2 | export type Level = "Beginner" | "Intermediate" | "Advanced"; |
| 3 | |
| 4 | export 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 | |
| 17 | export 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) |
| 22 | export function lessonKey(l: Pick<LessonMeta, "field" | "slug">): string { |
| 23 | return `${l.field}/${l.slug}`; |
| 24 | } |
| 25 | |
| 26 | export 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 | } |