| 1 | /** |
| 2 | * The templates g1t ships for folios. Docs' page templates |
| 3 | * (src/templates.ts) are the doc kind's, as they are; each later kind |
| 4 | * adds its own here (slides in Phase 4, dashboards in 5b, designs in 6b). |
| 5 | * A workspace's own are in `folio_templates`. Pure. |
| 6 | */ |
| 7 | import type { FolioKind, FolioTemplate } from "@g1t/contracts"; |
| 8 | |
| 9 | import { BUILTIN_TEMPLATES } from "../templates.ts"; |
| 10 | |
| 11 | /** Built-in ids are `builtin:<kind>:<slug>`; a doc's old `builtin:<slug>` is still found. */ |
| 12 | export const BUILTIN_FOLIO_TEMPLATES: FolioTemplate[] = BUILTIN_TEMPLATES.map((t) => ({ |
| 13 | id: `builtin:doc:${t.id.replace(/^builtin:/, "")}`, |
| 14 | kind: "doc" as const, |
| 15 | name: t.name, |
| 16 | description: t.description, |
| 17 | icon: t.icon, |
| 18 | builtin: true, |
| 19 | body: t.markdown, |
| 20 | created_by: null, |
| 21 | })); |
| 22 | |
| 23 | export function builtinFolioTemplate(id: string): FolioTemplate | null { |
| 24 | const wanted = String(id ?? ""); |
| 25 | return BUILTIN_FOLIO_TEMPLATES.find((t) => t.id === wanted || t.id === `builtin:doc:${wanted.replace(/^builtin:/, "")}`) ?? null; |
| 26 | } |
| 27 | |
| 28 | export function builtinFolioTemplates(kind?: FolioKind | null): FolioTemplate[] { |
| 29 | return kind ? BUILTIN_FOLIO_TEMPLATES.filter((t) => t.kind === kind) : BUILTIN_FOLIO_TEMPLATES; |
| 30 | } |