AI Resource Pro / website · airesourcepro.com / src / lib / tutorial-types.ts
| 1 | // Client-safe tutorial types and helpers (lib/tutorials.ts reads the filesystem) |
| 2 | import type { TrackSlug } from "@/lib/tracks"; |
| 3 | |
| 4 | export type Level = "Beginner" | "Intermediate" | "Advanced"; |
| 5 | |
| 6 | export type TutorialMeta = { |
| 7 | slug: string; |
| 8 | track: TrackSlug; |
| 9 | title: string; |
| 10 | description: string; |
| 11 | level: Level; |
| 12 | minutes: number; |
| 13 | publishedAt: string; |
| 14 | // Set when a published tutorial is revised (front matter `updatedAt`); shown as "Updated" and sent as dateModified |
| 15 | updatedAt?: string; |
| 16 | video?: string; |
| 17 | // The video's original publish time as ISO 8601 with a time zone (front matter `videoUploadedAt`); sent as uploadDate |
| 18 | videoUploadedAt?: string; |
| 19 | // True only when the matching WebVTT caption track is published alongside the video. |
| 20 | videoCaptions?: boolean; |
| 21 | // Shows a "Video coming soon" box where the video will go, until `video` is set |
| 22 | videoComingSoon?: boolean; |
| 23 | draft: boolean; |
| 24 | // Cover image path: the tutorial's own cover if one was rendered, else its track's (see scripts/covers) |
| 25 | cover: string; |
| 26 | }; |
| 27 | |
| 28 | // The date a tutorial last changed: its update date if it has one, else its publish date |
| 29 | export function lastModified(t: Pick<TutorialMeta, "publishedAt" | "updatedAt">): string { |
| 30 | return t.updatedAt || t.publishedAt; |
| 31 | } |
| 32 | |
| 33 | // Saved tutorials are stored in the database by this key |
| 34 | export function tutorialKey(t: Pick<TutorialMeta, "track" | "slug">): string { |
| 35 | return `${t.track}/${t.slug}`; |
| 36 | } |