@kurbo/dkit 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +24 -0
  2. package/dist/bin.js +8066 -0
  3. package/dist/bin.js.map +1 -0
  4. package/package.json +58 -0
  5. package/vendor/registry/blocks/blog-detail/module.json +27 -0
  6. package/vendor/registry/blocks/blog-detail/ui/minimal/next/blog-detail.tsx +26 -0
  7. package/vendor/registry/blocks/blog-detail/ui/minimal/nuxt/BlogDetail.vue +27 -0
  8. package/vendor/registry/blocks/blog-detail/ui/shadcn/next/blog-detail.tsx +106 -0
  9. package/vendor/registry/blocks/blog-detail/ui/shadcn/nuxt/BlogDetail.vue +116 -0
  10. package/vendor/registry/blocks/blog-list/module.json +26 -0
  11. package/vendor/registry/blocks/blog-list/ui/minimal/next/blog-list.tsx +130 -0
  12. package/vendor/registry/blocks/blog-list/ui/minimal/nuxt/BlogList.vue +62 -0
  13. package/vendor/registry/blocks/blog-list/ui/shadcn/next/blog-list.tsx +109 -0
  14. package/vendor/registry/blocks/blog-list/ui/shadcn/nuxt/BlogList.vue +100 -0
  15. package/vendor/registry/blocks/blog-list-cards/module.json +27 -0
  16. package/vendor/registry/blocks/blog-list-cards/ui/minimal/next/blog-list-cards.tsx +130 -0
  17. package/vendor/registry/blocks/blog-list-cards/ui/minimal/nuxt/BlogListCards.vue +114 -0
  18. package/vendor/registry/blocks/blog-list-cards/ui/shadcn/next/blog-list-cards.tsx +119 -0
  19. package/vendor/registry/blocks/blog-list-cards/ui/shadcn/nuxt/BlogListCards.vue +113 -0
  20. package/vendor/registry/blocks/booking-form-ui/module.json +15 -0
  21. package/vendor/registry/blocks/booking-form-ui/ui/minimal/next/booking-form.tsx +89 -0
  22. package/vendor/registry/blocks/booking-form-ui/ui/shadcn/next/booking-form.tsx +92 -0
  23. package/vendor/registry/blocks/contact-form-ui/module.json +27 -0
  24. package/vendor/registry/blocks/contact-form-ui/ui/minimal/next/contact-form.tsx +45 -0
  25. package/vendor/registry/blocks/contact-form-ui/ui/minimal/nuxt/ContactForm.vue +79 -0
  26. package/vendor/registry/blocks/contact-form-ui/ui/shadcn/next/contact-form.tsx +55 -0
  27. package/vendor/registry/blocks/contact-form-ui/ui/shadcn/nuxt/ContactForm.vue +92 -0
  28. package/vendor/registry/blocks/faq-list/module.json +15 -0
  29. package/vendor/registry/blocks/faq-list/ui/minimal/next/faq-list.tsx +78 -0
  30. package/vendor/registry/blocks/faq-list/ui/shadcn/next/faq-list.tsx +77 -0
  31. package/vendor/registry/blocks/maintenance-gate/module.json +13 -0
  32. package/vendor/registry/blocks/maintenance-gate/ui/minimal/next/maintenance-gate.tsx +135 -0
  33. package/vendor/registry/blocks/maintenance-gate/ui/shadcn/next/maintenance-gate.tsx +87 -0
  34. package/vendor/registry/blocks/nav-footer/module.json +13 -0
  35. package/vendor/registry/blocks/nav-footer/ui/minimal/next/nav-footer.tsx +55 -0
  36. package/vendor/registry/blocks/nav-footer/ui/shadcn/next/nav-footer.tsx +41 -0
  37. package/vendor/registry/blocks/nav-header/module.json +14 -0
  38. package/vendor/registry/blocks/nav-header/ui/minimal/next/nav-header.tsx +244 -0
  39. package/vendor/registry/blocks/nav-header/ui/shadcn/next/nav-header-client.tsx +185 -0
  40. package/vendor/registry/blocks/nav-header/ui/shadcn/next/nav-header.tsx +12 -0
  41. package/vendor/registry/blocks/page-detail/module.json +26 -0
  42. package/vendor/registry/blocks/page-detail/ui/minimal/next/page-detail.tsx +26 -0
  43. package/vendor/registry/blocks/page-detail/ui/minimal/nuxt/PageDetail.vue +26 -0
  44. package/vendor/registry/blocks/page-detail/ui/shadcn/next/page-detail.tsx +61 -0
  45. package/vendor/registry/blocks/page-detail/ui/shadcn/nuxt/PageDetail.vue +62 -0
  46. package/vendor/registry/blocks/project-detail/module.json +15 -0
  47. package/vendor/registry/blocks/project-detail/ui/minimal/next/project-detail.tsx +58 -0
  48. package/vendor/registry/blocks/project-detail/ui/shadcn/next/project-detail.tsx +91 -0
  49. package/vendor/registry/blocks/project-list/module.json +14 -0
  50. package/vendor/registry/blocks/project-list/ui/minimal/next/project-list.tsx +104 -0
  51. package/vendor/registry/blocks/project-list/ui/shadcn/next/project-list.tsx +81 -0
  52. package/vendor/registry/blocks/project-list-cards/module.json +15 -0
  53. package/vendor/registry/blocks/project-list-cards/ui/minimal/next/project-list-cards.tsx +125 -0
  54. package/vendor/registry/blocks/project-list-cards/ui/shadcn/next/project-list-cards.tsx +94 -0
  55. package/vendor/registry/blocks/projects-carousel/module.json +15 -0
  56. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel-client.tsx +239 -0
  57. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel.tsx +24 -0
  58. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel-client.tsx +102 -0
  59. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel.tsx +24 -0
  60. package/vendor/registry/blocks/service-detail/module.json +15 -0
  61. package/vendor/registry/blocks/service-detail/ui/minimal/next/service-detail.tsx +49 -0
  62. package/vendor/registry/blocks/service-detail/ui/shadcn/next/service-detail.tsx +75 -0
  63. package/vendor/registry/blocks/service-list/module.json +14 -0
  64. package/vendor/registry/blocks/service-list/ui/minimal/next/service-list.tsx +103 -0
  65. package/vendor/registry/blocks/service-list/ui/shadcn/next/service-list.tsx +80 -0
  66. package/vendor/registry/blocks/service-list-cards/module.json +15 -0
  67. package/vendor/registry/blocks/service-list-cards/ui/minimal/next/service-list-cards.tsx +124 -0
  68. package/vendor/registry/blocks/service-list-cards/ui/shadcn/next/service-list-cards.tsx +92 -0
  69. package/vendor/registry/blocks/site-brand/module.json +13 -0
  70. package/vendor/registry/blocks/site-brand/ui/minimal/next/site-brand.tsx +61 -0
  71. package/vendor/registry/blocks/site-brand/ui/shadcn/next/site-brand.tsx +48 -0
  72. package/vendor/registry/blocks/site-logo/module.json +13 -0
  73. package/vendor/registry/blocks/site-logo/ui/minimal/next/site-logo.tsx +37 -0
  74. package/vendor/registry/blocks/site-logo/ui/shadcn/next/site-logo.tsx +34 -0
  75. package/vendor/registry/blocks/social-links/module.json +13 -0
  76. package/vendor/registry/blocks/social-links/ui/minimal/next/social-links.tsx +55 -0
  77. package/vendor/registry/blocks/social-links/ui/shadcn/next/social-links.tsx +46 -0
  78. package/vendor/registry/blocks/team-detail/module.json +15 -0
  79. package/vendor/registry/blocks/team-detail/ui/minimal/next/team-detail.tsx +113 -0
  80. package/vendor/registry/blocks/team-detail/ui/shadcn/next/team-detail.tsx +77 -0
  81. package/vendor/registry/blocks/team-list/module.json +14 -0
  82. package/vendor/registry/blocks/team-list/ui/minimal/next/team-list.tsx +113 -0
  83. package/vendor/registry/blocks/team-list/ui/shadcn/next/team-list.tsx +77 -0
  84. package/vendor/registry/blocks/team-list-cards/module.json +15 -0
  85. package/vendor/registry/blocks/team-list-cards/ui/minimal/next/team-list-cards.tsx +111 -0
  86. package/vendor/registry/blocks/team-list-cards/ui/shadcn/next/team-list-cards.tsx +83 -0
  87. package/vendor/registry/blocks/testimonials-carousel/module.json +15 -0
  88. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel-client.tsx +230 -0
  89. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel.tsx +23 -0
  90. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel-client.tsx +91 -0
  91. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel.tsx +23 -0
  92. package/vendor/registry/blocks/testimonials-list/module.json +14 -0
  93. package/vendor/registry/blocks/testimonials-list/ui/minimal/next/testimonials-list.tsx +109 -0
  94. package/vendor/registry/blocks/testimonials-list/ui/shadcn/next/testimonials-list.tsx +72 -0
  95. package/vendor/registry/blocks/testimonials-list-cards/module.json +15 -0
  96. package/vendor/registry/blocks/testimonials-list-cards/ui/minimal/next/testimonials-list-cards.tsx +114 -0
  97. package/vendor/registry/blocks/testimonials-list-cards/ui/shadcn/next/testimonials-list-cards.tsx +72 -0
  98. package/vendor/registry/core/languages/policies.json +25 -0
  99. package/vendor/registry/core/languages/seed.json +16 -0
  100. package/vendor/registry/core/languages/snapshot.json +94 -0
  101. package/vendor/registry/modules/blog/access/policies.json +49 -0
  102. package/vendor/registry/modules/blog/access/policies.multilocale.json +67 -0
  103. package/vendor/registry/modules/blog/lib.multilocale.ts +552 -0
  104. package/vendor/registry/modules/blog/lib.ts +346 -0
  105. package/vendor/registry/modules/blog/module.json +50 -0
  106. package/vendor/registry/modules/blog/schema/snapshot.json +701 -0
  107. package/vendor/registry/modules/blog/schema/snapshot.multilocale.json +884 -0
  108. package/vendor/registry/modules/blog/services/ATTRIBUTION.md +8 -0
  109. package/vendor/registry/modules/blog/services/assets/ada-lovelace-avatar.jpg +0 -0
  110. package/vendor/registry/modules/blog/services/assets/hello-from-dkit-cover.jpg +0 -0
  111. package/vendor/registry/modules/blog/services/seed.json +70 -0
  112. package/vendor/registry/modules/blog/services/seed.multilocale.json +90 -0
  113. package/vendor/registry/modules/blog/types.multilocale.ts +96 -0
  114. package/vendor/registry/modules/blog/types.ts +62 -0
  115. package/vendor/registry/modules/booking-form/access/policies.json +25 -0
  116. package/vendor/registry/modules/booking-form/access/policies.multilocale.json +27 -0
  117. package/vendor/registry/modules/booking-form/lib.multilocale.ts +71 -0
  118. package/vendor/registry/modules/booking-form/lib.ts +77 -0
  119. package/vendor/registry/modules/booking-form/module.json +32 -0
  120. package/vendor/registry/modules/booking-form/schema/snapshot.json +294 -0
  121. package/vendor/registry/modules/booking-form/schema/snapshot.multilocale.json +467 -0
  122. package/vendor/registry/modules/booking-form/services/flows.json +19 -0
  123. package/vendor/registry/modules/booking-form/types.multilocale.ts +29 -0
  124. package/vendor/registry/modules/booking-form/types.ts +27 -0
  125. package/vendor/registry/modules/contact-form/access/policies.json +25 -0
  126. package/vendor/registry/modules/contact-form/access/policies.multilocale.json +27 -0
  127. package/vendor/registry/modules/contact-form/lib.multilocale.ts +65 -0
  128. package/vendor/registry/modules/contact-form/lib.ts +67 -0
  129. package/vendor/registry/modules/contact-form/module.json +32 -0
  130. package/vendor/registry/modules/contact-form/schema/snapshot.json +193 -0
  131. package/vendor/registry/modules/contact-form/schema/snapshot.multilocale.json +293 -0
  132. package/vendor/registry/modules/contact-form/services/flows.json +19 -0
  133. package/vendor/registry/modules/contact-form/types.multilocale.ts +21 -0
  134. package/vendor/registry/modules/contact-form/types.ts +19 -0
  135. package/vendor/registry/modules/faq/access/policies.json +25 -0
  136. package/vendor/registry/modules/faq/access/policies.multilocale.json +18 -0
  137. package/vendor/registry/modules/faq/lib.multilocale.ts +120 -0
  138. package/vendor/registry/modules/faq/lib.ts +73 -0
  139. package/vendor/registry/modules/faq/module.json +31 -0
  140. package/vendor/registry/modules/faq/schema/snapshot.json +180 -0
  141. package/vendor/registry/modules/faq/schema/snapshot.multilocale.json +116 -0
  142. package/vendor/registry/modules/faq/services/seed.json +38 -0
  143. package/vendor/registry/modules/faq/services/seed.multilocale.json +32 -0
  144. package/vendor/registry/modules/faq/types.multilocale.ts +31 -0
  145. package/vendor/registry/modules/faq/types.ts +17 -0
  146. package/vendor/registry/modules/navigation/access/policies.json +31 -0
  147. package/vendor/registry/modules/navigation/access/policies.multilocale.json +51 -0
  148. package/vendor/registry/modules/navigation/lib.multilocale.ts +198 -0
  149. package/vendor/registry/modules/navigation/lib.ts +252 -0
  150. package/vendor/registry/modules/navigation/module.json +46 -0
  151. package/vendor/registry/modules/navigation/schema/snapshot.json +453 -0
  152. package/vendor/registry/modules/navigation/schema/snapshot.multilocale.json +864 -0
  153. package/vendor/registry/modules/navigation/services/seed.json +103 -0
  154. package/vendor/registry/modules/navigation/services/seed.multilocale.json +88 -0
  155. package/vendor/registry/modules/navigation/types.multilocale.ts +60 -0
  156. package/vendor/registry/modules/navigation/types.ts +44 -0
  157. package/vendor/registry/modules/pages/access/policies.json +25 -0
  158. package/vendor/registry/modules/pages/access/policies.multilocale.json +18 -0
  159. package/vendor/registry/modules/pages/lib.multilocale.ts +166 -0
  160. package/vendor/registry/modules/pages/lib.ts +123 -0
  161. package/vendor/registry/modules/pages/module.json +39 -0
  162. package/vendor/registry/modules/pages/schema/snapshot.json +247 -0
  163. package/vendor/registry/modules/pages/schema/snapshot.multilocale.json +187 -0
  164. package/vendor/registry/modules/pages/services/seed.json +24 -0
  165. package/vendor/registry/modules/pages/services/seed.multilocale.json +34 -0
  166. package/vendor/registry/modules/pages/types.multilocale.ts +37 -0
  167. package/vendor/registry/modules/pages/types.ts +21 -0
  168. package/vendor/registry/modules/projects/access/policies.json +31 -0
  169. package/vendor/registry/modules/projects/access/policies.multilocale.json +43 -0
  170. package/vendor/registry/modules/projects/lib.multilocale.ts +111 -0
  171. package/vendor/registry/modules/projects/lib.ts +138 -0
  172. package/vendor/registry/modules/projects/module.json +48 -0
  173. package/vendor/registry/modules/projects/schema/snapshot.json +348 -0
  174. package/vendor/registry/modules/projects/schema/snapshot.multilocale.json +577 -0
  175. package/vendor/registry/modules/projects/services/ATTRIBUTION.md +7 -0
  176. package/vendor/registry/modules/projects/services/assets/brand-identity-cover.jpg +0 -0
  177. package/vendor/registry/modules/projects/services/seed.json +40 -0
  178. package/vendor/registry/modules/projects/services/seed.multilocale.json +31 -0
  179. package/vendor/registry/modules/projects/types.multilocale.ts +38 -0
  180. package/vendor/registry/modules/projects/types.ts +28 -0
  181. package/vendor/registry/modules/services/access/policies.json +31 -0
  182. package/vendor/registry/modules/services/access/policies.multilocale.json +43 -0
  183. package/vendor/registry/modules/services/lib.multilocale.ts +109 -0
  184. package/vendor/registry/modules/services/lib.ts +134 -0
  185. package/vendor/registry/modules/services/module.json +47 -0
  186. package/vendor/registry/modules/services/schema/snapshot.json +305 -0
  187. package/vendor/registry/modules/services/schema/snapshot.multilocale.json +510 -0
  188. package/vendor/registry/modules/services/services/ATTRIBUTION.md +8 -0
  189. package/vendor/registry/modules/services/services/assets/design-development.jpg +0 -0
  190. package/vendor/registry/modules/services/services/assets/strategy-consulting.jpg +0 -0
  191. package/vendor/registry/modules/services/services/seed.json +44 -0
  192. package/vendor/registry/modules/services/services/seed.multilocale.json +31 -0
  193. package/vendor/registry/modules/services/types.multilocale.ts +36 -0
  194. package/vendor/registry/modules/services/types.ts +26 -0
  195. package/vendor/registry/modules/settings/access/policies.json +31 -0
  196. package/vendor/registry/modules/settings/access/policies.multilocale.json +43 -0
  197. package/vendor/registry/modules/settings/lib.multilocale.ts +158 -0
  198. package/vendor/registry/modules/settings/lib.ts +259 -0
  199. package/vendor/registry/modules/settings/module.json +33 -0
  200. package/vendor/registry/modules/settings/schema/snapshot.json +315 -0
  201. package/vendor/registry/modules/settings/schema/snapshot.multilocale.json +586 -0
  202. package/vendor/registry/modules/settings/services/assets/dkit-logo.svg +4 -0
  203. package/vendor/registry/modules/settings/services/seed.json +31 -0
  204. package/vendor/registry/modules/settings/services/seed.multilocale.json +42 -0
  205. package/vendor/registry/modules/settings/types.multilocale.ts +72 -0
  206. package/vendor/registry/modules/settings/types.ts +94 -0
  207. package/vendor/registry/modules/team/access/policies.json +31 -0
  208. package/vendor/registry/modules/team/access/policies.multilocale.json +43 -0
  209. package/vendor/registry/modules/team/lib.multilocale.ts +88 -0
  210. package/vendor/registry/modules/team/lib.ts +120 -0
  211. package/vendor/registry/modules/team/module.json +47 -0
  212. package/vendor/registry/modules/team/schema/snapshot.json +295 -0
  213. package/vendor/registry/modules/team/schema/snapshot.multilocale.json +525 -0
  214. package/vendor/registry/modules/team/services/ATTRIBUTION.md +8 -0
  215. package/vendor/registry/modules/team/services/assets/morgan-lee-photo.jpg +0 -0
  216. package/vendor/registry/modules/team/services/assets/taylor-kim-photo.jpg +0 -0
  217. package/vendor/registry/modules/team/services/seed.json +52 -0
  218. package/vendor/registry/modules/team/services/seed.multilocale.json +30 -0
  219. package/vendor/registry/modules/team/types.multilocale.ts +33 -0
  220. package/vendor/registry/modules/team/types.ts +27 -0
  221. package/vendor/registry/modules/testimonials/access/policies.json +31 -0
  222. package/vendor/registry/modules/testimonials/access/policies.multilocale.json +43 -0
  223. package/vendor/registry/modules/testimonials/lib.multilocale.ts +93 -0
  224. package/vendor/registry/modules/testimonials/lib.ts +85 -0
  225. package/vendor/registry/modules/testimonials/module.json +41 -0
  226. package/vendor/registry/modules/testimonials/schema/snapshot.json +248 -0
  227. package/vendor/registry/modules/testimonials/schema/snapshot.multilocale.json +462 -0
  228. package/vendor/registry/modules/testimonials/services/ATTRIBUTION.md +8 -0
  229. package/vendor/registry/modules/testimonials/services/assets/jane-doe-avatar.jpg +0 -0
  230. package/vendor/registry/modules/testimonials/services/assets/sample-author-avatar.jpg +0 -0
  231. package/vendor/registry/modules/testimonials/services/seed.json +49 -0
  232. package/vendor/registry/modules/testimonials/services/seed.multilocale.json +30 -0
  233. package/vendor/registry/modules/testimonials/types.multilocale.ts +27 -0
  234. package/vendor/registry/modules/testimonials/types.ts +22 -0
  235. package/vendor/registry/registry.json +832 -0
  236. package/vendor/registry/shared/helpers.ts +16 -0
  237. package/vendor/registry/shared/i18n.ts +74 -0
  238. package/vendor/registry/shared/minimal.css +83 -0
  239. package/vendor/registry/shared/paths.ts +50 -0
  240. package/vendor/registry/shared/prose.css +113 -0
  241. package/vendor/registry/tsconfig.json +49 -0
@@ -0,0 +1,111 @@
1
+ import {
2
+ directusAssetUrl,
3
+ directusFileId,
4
+ dkitQueryFailed,
5
+ getDirectus,
6
+ readItem,
7
+ readItems,
8
+ } from "@/lib/dkit/client";
9
+ import { collections } from "@/lib/dkit/config";
10
+ import { queryLimit, statusFilter } from "@/lib/dkit/helpers";
11
+ import {
12
+ isUsableTranslation,
13
+ pickTranslation,
14
+ requireLocaleTranslation,
15
+ resolveLocale,
16
+ translationsDeepFilter,
17
+ } from "@/lib/dkit/i18n";
18
+ import type { DirectusFileRef, GetProjectBySlugOptions, GetProjectsOptions, Project, ProjectTranslation } from "./types.multilocale";
19
+
20
+ export type { DirectusFileRef, GetProjectBySlugOptions, GetProjectsOptions, Project, ProjectTranslation } from "./types.multilocale";
21
+
22
+ function flattenProject(row: Record<string, unknown>, locale: string): Project | null {
23
+ const trans = pickTranslation(row.translations as ProjectTranslation[] | undefined, locale);
24
+ if (!isUsableTranslation(trans)) return null;
25
+
26
+ return {
27
+ id: row.id as string,
28
+ status: row.status as Project["status"],
29
+ title: trans!.title!,
30
+ slug: trans!.slug!,
31
+ summary: trans?.summary ?? null,
32
+ body: trans?.body ?? null,
33
+ featured_image: row.featured_image as Project["featured_image"],
34
+ client: (row.client as string | null) ?? null,
35
+ location: trans?.location ?? null,
36
+ completed_on: (row.completed_on as string | null) ?? null,
37
+ sort: (row.sort as number | null) ?? null,
38
+ };
39
+ }
40
+
41
+ const PROJECT_LIST_FIELDS = ["id", "status", "featured_image", "client", "completed_on", "sort", { translations: ["id", "languages_code", "title", "slug", "summary", "location"] }] as const;
42
+ const PROJECT_DETAIL_FIELDS = ["id", "status", "featured_image", "client", "completed_on", "sort", { translations: ["id", "languages_code", "title", "slug", "summary", "location", "body"] }] as const;
43
+
44
+ export function projectImageUrl(project: Project): string | null {
45
+ const id = directusFileId(project.featured_image as string | DirectusFileRef | null | undefined);
46
+ return id ? directusAssetUrl(id) : null;
47
+ }
48
+
49
+ export async function getProjects(options: GetProjectsOptions = {}): Promise<Project[]> {
50
+ const client = getDirectus(); if (!client) return [];
51
+ if (!collections.projects) { dkitQueryFailed('collections.projects missing — re-run `dkit add projects`'); return []; }
52
+ const locale = await resolveLocale(options.locale);
53
+ const status = statusFilter(options.status);
54
+ const and: Record<string, unknown>[] = [requireLocaleTranslation(locale)];
55
+ if (status) and.unshift(status);
56
+ const limit = queryLimit(options.limit);
57
+ try {
58
+ const rows = await client.request(readItems(collections.projects, {
59
+ filter: { _and: and },
60
+ deep: translationsDeepFilter(locale),
61
+ fields: [...PROJECT_LIST_FIELDS], sort: options.sort ?? ["sort", "-completed_on"],
62
+ ...(limit !== undefined ? { limit } : {}),
63
+ }));
64
+ return (rows as Record<string, unknown>[])
65
+ .map((r) => flattenProject(r, locale))
66
+ .filter((p): p is Project => p != null);
67
+ } catch (err) { dkitQueryFailed(`getProjects failed`, err); return []; }
68
+ }
69
+
70
+ export async function getProjectBySlug(slug: string, options: GetProjectBySlugOptions = {}): Promise<Project | null> {
71
+ const client = getDirectus(); if (!client) return null;
72
+ if (!collections.projects) { dkitQueryFailed("collections.projects missing"); return null; }
73
+ const locale = await resolveLocale(options.locale);
74
+ const status = statusFilter(options.status);
75
+ const and: Record<string, unknown>[] = [{
76
+ translations: {
77
+ _and: [
78
+ { languages_code: { _eq: locale } },
79
+ { slug: { _eq: slug } },
80
+ { title: { _nempty: true } },
81
+ ],
82
+ },
83
+ }];
84
+ if (status) and.unshift(status);
85
+ try {
86
+ const rows = await client.request(readItems(collections.projects, {
87
+ filter: { _and: and },
88
+ deep: translationsDeepFilter(locale),
89
+ fields: [...PROJECT_DETAIL_FIELDS],
90
+ limit: 1,
91
+ }));
92
+ const row = (rows as Record<string, unknown>[])[0]; return row ? flattenProject(row, locale) : null;
93
+ } catch (err) { dkitQueryFailed(`getProjectBySlug(${slug}) failed`, err); return null; }
94
+ }
95
+
96
+ export async function getProjectById(id: string, options: GetProjectBySlugOptions = {}): Promise<Project | null> {
97
+ const client = getDirectus(); if (!client) return null; if (!collections.projects) return null;
98
+ const locale = await resolveLocale(options.locale);
99
+ try {
100
+ const rows = await client.request(readItems(collections.projects, {
101
+ filter: {
102
+ _and: [{ id: { _eq: id } }, requireLocaleTranslation(locale)],
103
+ },
104
+ deep: translationsDeepFilter(locale),
105
+ fields: [...PROJECT_DETAIL_FIELDS],
106
+ limit: 1,
107
+ }));
108
+ const row = (rows as Record<string, unknown>[])[0];
109
+ return row ? flattenProject(row as Record<string, unknown>, locale) : null;
110
+ } catch (err) { dkitQueryFailed(`getProjectById(${id}) failed`, err); return null; }
111
+ }
@@ -0,0 +1,138 @@
1
+ import {
2
+ directusAssetUrl,
3
+ directusFileId,
4
+ dkitQueryFailed,
5
+ getDirectus,
6
+ readItem,
7
+ readItems,
8
+ } from "@/lib/dkit/client";
9
+ import { collections } from "@/lib/dkit/config";
10
+ import { queryLimit, statusFilter } from "@/lib/dkit/helpers";
11
+ import type {
12
+ DirectusFileRef,
13
+ GetProjectBySlugOptions,
14
+ GetProjectsOptions,
15
+ Project,
16
+ } from "./types";
17
+
18
+ export type {
19
+ DirectusFileRef,
20
+ GetProjectBySlugOptions,
21
+ GetProjectsOptions,
22
+ Project,
23
+ } from "./types";
24
+
25
+ const PROJECT_LIST_FIELDS = [
26
+ "id",
27
+ "status",
28
+ "title",
29
+ "slug",
30
+ "summary",
31
+ "featured_image",
32
+ "client",
33
+ "location",
34
+ "completed_on",
35
+ "sort",
36
+ ] as const;
37
+
38
+ const PROJECT_DETAIL_FIELDS = [
39
+ "id",
40
+ "status",
41
+ "title",
42
+ "slug",
43
+ "summary",
44
+ "body",
45
+ "featured_image",
46
+ "client",
47
+ "location",
48
+ "completed_on",
49
+ "sort",
50
+ ] as const;
51
+
52
+ export function projectImageUrl(project: Project): string | null {
53
+ const id = directusFileId(
54
+ project.featured_image as string | DirectusFileRef | null | undefined,
55
+ );
56
+ return id ? directusAssetUrl(id) : null;
57
+ }
58
+
59
+ /** Projects sorted by manual order, then newest completion, then title. */
60
+ export async function getProjects(
61
+ options: GetProjectsOptions = {},
62
+ ): Promise<Project[]> {
63
+ const client = getDirectus();
64
+ if (!client) return [];
65
+ if (!collections.projects) {
66
+ dkitQueryFailed(
67
+ 'collections.projects missing from lib/dkit/config — re-run `dkit add projects`',
68
+ );
69
+ return [];
70
+ }
71
+ const status = statusFilter(options.status);
72
+ const and: Record<string, unknown>[] = [];
73
+ if (status) and.push(status);
74
+ const limit = queryLimit(options.limit);
75
+ try {
76
+ return await client.request(
77
+ readItems(collections.projects, {
78
+ filter: and.length ? { _and: and } : undefined,
79
+ fields: [...PROJECT_LIST_FIELDS],
80
+ sort: options.sort ?? ["sort", "-completed_on", "title"],
81
+ ...(limit !== undefined ? { limit } : {}),
82
+ }),
83
+ );
84
+ } catch (err) {
85
+ dkitQueryFailed(
86
+ `getProjects failed (collection=${collections.projects})`,
87
+ err,
88
+ );
89
+ return [];
90
+ }
91
+ }
92
+
93
+ export async function getProjectBySlug(
94
+ slug: string,
95
+ options: GetProjectBySlugOptions = {},
96
+ ): Promise<Project | null> {
97
+ const client = getDirectus();
98
+ if (!client) return null;
99
+ if (!collections.projects) {
100
+ dkitQueryFailed("collections.projects missing from lib/dkit/config");
101
+ return null;
102
+ }
103
+ const status = statusFilter(options.status);
104
+ const and: Record<string, unknown>[] = [{ slug: { _eq: slug } }];
105
+ if (status) and.unshift(status);
106
+ try {
107
+ const rows = await client.request(
108
+ readItems(collections.projects, {
109
+ filter: { _and: and },
110
+ fields: [...PROJECT_DETAIL_FIELDS],
111
+ limit: 1,
112
+ }),
113
+ );
114
+ return rows[0] ?? null;
115
+ } catch (err) {
116
+ dkitQueryFailed(
117
+ `getProjectBySlug(${slug}) failed (collection=${collections.projects})`,
118
+ err,
119
+ );
120
+ return null;
121
+ }
122
+ }
123
+
124
+ export async function getProjectById(id: string): Promise<Project | null> {
125
+ const client = getDirectus();
126
+ if (!client) return null;
127
+ if (!collections.projects) return null;
128
+ try {
129
+ return await client.request(
130
+ readItem(collections.projects, id, {
131
+ fields: [...PROJECT_DETAIL_FIELDS],
132
+ }),
133
+ );
134
+ } catch (err) {
135
+ dkitQueryFailed(`getProjectById(${id}) failed`, err);
136
+ return null;
137
+ }
138
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "type": "dkit:module",
3
+ "id": "projects",
4
+ "title": "Projects",
5
+ "description": "Portfolio / case studies for makers, builders, and studios",
6
+ "version": "0.1.0",
7
+ "directus": {
8
+ "min": "11.0.0"
9
+ },
10
+ "dependencies": [
11
+ "@directus/sdk"
12
+ ],
13
+ "layers": [
14
+ "schema",
15
+ "access",
16
+ "services",
17
+ "types"
18
+ ],
19
+ "defaultBlocks": [
20
+ "project-list",
21
+ "project-detail"
22
+ ],
23
+ "templates": {
24
+ "list": {
25
+ "default": "project-list",
26
+ "options": [
27
+ "project-list",
28
+ "project-list-cards",
29
+ "projects-carousel"
30
+ ]
31
+ },
32
+ "detail": {
33
+ "default": "project-detail",
34
+ "options": [
35
+ "project-detail"
36
+ ]
37
+ }
38
+ },
39
+ "collections": [
40
+ "portfolio",
41
+ "projects"
42
+ ],
43
+ "defaultBasePath": "/projects",
44
+ "multilocale": {
45
+ "supported": true,
46
+ "mode": "translations"
47
+ }
48
+ }
@@ -0,0 +1,348 @@
1
+ {
2
+ "format": "dkit.rest",
3
+ "collections": [
4
+ {
5
+ "collection": "portfolio",
6
+ "schema": null,
7
+ "meta": {
8
+ "icon": "work",
9
+ "color": "#0F766E",
10
+ "collapse": "open",
11
+ "translations": [
12
+ {
13
+ "language": "en-US",
14
+ "translation": "Portfolio",
15
+ "singular": "Portfolio",
16
+ "plural": "Portfolio"
17
+ }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ "collection": "projects",
23
+ "schema": {},
24
+ "meta": {
25
+ "icon": "folder_special",
26
+ "color": "#0F766E",
27
+ "group": "portfolio",
28
+ "display_template": "{{title}}",
29
+ "archive_field": "status",
30
+ "archive_value": "archived",
31
+ "unarchive_value": "draft",
32
+ "archive_app_filter": true,
33
+ "sort_field": "sort",
34
+ "sort": 1,
35
+ "translations": [
36
+ {
37
+ "language": "en-US",
38
+ "translation": "Projects",
39
+ "singular": "Project",
40
+ "plural": "Projects"
41
+ }
42
+ ],
43
+ "note": "Portfolio case studies published to the site"
44
+ },
45
+ "fields": [
46
+ {
47
+ "field": "id",
48
+ "type": "uuid",
49
+ "meta": {
50
+ "hidden": true,
51
+ "readonly": true,
52
+ "interface": "input",
53
+ "special": ["uuid"],
54
+ "sort": 1,
55
+ "width": "full",
56
+ "translations": [
57
+ { "language": "en-US", "translation": "ID" }
58
+ ]
59
+ },
60
+ "schema": {
61
+ "is_primary_key": true,
62
+ "length": 36,
63
+ "has_auto_increment": false
64
+ }
65
+ },
66
+ {
67
+ "field": "status",
68
+ "type": "string",
69
+ "meta": {
70
+ "interface": "select-dropdown",
71
+ "display": "labels",
72
+ "width": "half",
73
+ "sort": 2,
74
+ "options": {
75
+ "choices": [
76
+ { "text": "Published", "value": "published" },
77
+ { "text": "Draft", "value": "draft" },
78
+ { "text": "Archived", "value": "archived" }
79
+ ]
80
+ },
81
+ "display_options": {
82
+ "choices": [
83
+ {
84
+ "text": "Published",
85
+ "value": "published",
86
+ "foreground": "#FFFFFF",
87
+ "background": "#0F766E"
88
+ },
89
+ {
90
+ "text": "Draft",
91
+ "value": "draft",
92
+ "foreground": "#44403C",
93
+ "background": "#E7E5E4"
94
+ },
95
+ {
96
+ "text": "Archived",
97
+ "value": "archived",
98
+ "foreground": "#FFFFFF",
99
+ "background": "#A8A29E"
100
+ }
101
+ ]
102
+ },
103
+ "translations": [
104
+ { "language": "en-US", "translation": "Status" }
105
+ ],
106
+ "note": "Only published projects appear on the public site",
107
+ "validation": {
108
+ "_and": [
109
+ {
110
+ "status": {
111
+ "_in": ["published", "draft", "archived"]
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ "validation_message": "Choose Published, Draft, or Archived."
117
+ },
118
+ "schema": { "default_value": "draft", "is_nullable": false }
119
+ },
120
+ {
121
+ "field": "sort",
122
+ "type": "integer",
123
+ "meta": {
124
+ "hidden": true,
125
+ "interface": "input",
126
+ "width": "full",
127
+ "sort": 3,
128
+ "translations": [
129
+ { "language": "en-US", "translation": "Sort" }
130
+ ]
131
+ },
132
+ "schema": {}
133
+ },
134
+ {
135
+ "field": "title",
136
+ "type": "string",
137
+ "meta": {
138
+ "interface": "input",
139
+ "required": true,
140
+ "width": "full",
141
+ "sort": 4,
142
+ "options": { "trim": true },
143
+ "translations": [
144
+ { "language": "en-US", "translation": "Title" }
145
+ ],
146
+ "validation": {
147
+ "_and": [{ "title": { "_regex": "^.{1,200}$" } }]
148
+ },
149
+ "validation_message": "Title is required (max 200 characters)."
150
+ },
151
+ "schema": { "is_nullable": false, "max_length": 200 }
152
+ },
153
+ {
154
+ "field": "slug",
155
+ "type": "string",
156
+ "meta": {
157
+ "interface": "input",
158
+ "required": true,
159
+ "width": "half",
160
+ "sort": 5,
161
+ "options": { "trim": true, "slug": true },
162
+ "translations": [
163
+ { "language": "en-US", "translation": "Slug" }
164
+ ],
165
+ "note": "URL-friendly identifier (unique)",
166
+ "validation": {
167
+ "_and": [
168
+ {
169
+ "slug": {
170
+ "_regex": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
171
+ }
172
+ }
173
+ ]
174
+ },
175
+ "validation_message": "Use lowercase letters, numbers, and hyphens only."
176
+ },
177
+ "schema": { "is_nullable": false, "is_unique": true, "max_length": 200 }
178
+ },
179
+ {
180
+ "field": "summary",
181
+ "type": "text",
182
+ "meta": {
183
+ "interface": "input-multiline",
184
+ "width": "full",
185
+ "sort": 6,
186
+ "translations": [
187
+ { "language": "en-US", "translation": "Summary" }
188
+ ],
189
+ "note": "Short description shown on listing pages",
190
+ "validation": {
191
+ "_and": [
192
+ {
193
+ "_or": [
194
+ { "summary": { "_null": true } },
195
+ { "summary": { "_empty": true } },
196
+ { "summary": { "_regex": "^[\\s\\S]{1,500}$" } }
197
+ ]
198
+ }
199
+ ]
200
+ },
201
+ "validation_message": "Summary must be at most 500 characters."
202
+ },
203
+ "schema": {}
204
+ },
205
+ {
206
+ "field": "featured_image",
207
+ "type": "uuid",
208
+ "meta": {
209
+ "interface": "file-image",
210
+ "special": ["file"],
211
+ "display": "image",
212
+ "width": "half",
213
+ "sort": 7,
214
+ "translations": [
215
+ { "language": "en-US", "translation": "Featured image" }
216
+ ],
217
+ "note": "Cover image shown on list and detail pages"
218
+ },
219
+ "schema": {}
220
+ },
221
+ {
222
+ "field": "client",
223
+ "type": "string",
224
+ "meta": {
225
+ "interface": "input",
226
+ "width": "half",
227
+ "sort": 8,
228
+ "options": { "trim": true },
229
+ "translations": [
230
+ { "language": "en-US", "translation": "Client" }
231
+ ],
232
+ "note": "Client or company name",
233
+ "validation": {
234
+ "_and": [
235
+ {
236
+ "_or": [
237
+ { "client": { "_null": true } },
238
+ { "client": { "_empty": true } },
239
+ { "client": { "_regex": "^.{1,120}$" } }
240
+ ]
241
+ }
242
+ ]
243
+ },
244
+ "validation_message": "Client name must be at most 120 characters."
245
+ },
246
+ "schema": { "max_length": 120 }
247
+ },
248
+ {
249
+ "field": "location",
250
+ "type": "string",
251
+ "meta": {
252
+ "interface": "input",
253
+ "width": "half",
254
+ "sort": 9,
255
+ "options": { "trim": true },
256
+ "translations": [
257
+ { "language": "en-US", "translation": "Location" }
258
+ ],
259
+ "note": "City, region, or remote",
260
+ "validation": {
261
+ "_and": [
262
+ {
263
+ "_or": [
264
+ { "location": { "_null": true } },
265
+ { "location": { "_empty": true } },
266
+ { "location": { "_regex": "^.{1,120}$" } }
267
+ ]
268
+ }
269
+ ]
270
+ },
271
+ "validation_message": "Location must be at most 120 characters."
272
+ },
273
+ "schema": { "max_length": 120 }
274
+ },
275
+ {
276
+ "field": "completed_on",
277
+ "type": "date",
278
+ "meta": {
279
+ "interface": "datetime",
280
+ "display": "datetime",
281
+ "display_options": { "relative": false },
282
+ "width": "half",
283
+ "sort": 10,
284
+ "translations": [
285
+ { "language": "en-US", "translation": "Completed on" }
286
+ ],
287
+ "note": "Date the project was finished (optional)"
288
+ },
289
+ "schema": {}
290
+ },
291
+ {
292
+ "field": "body",
293
+ "type": "text",
294
+ "meta": {
295
+ "interface": "input-rich-text-html",
296
+ "width": "fill",
297
+ "sort": 11,
298
+ "options": {
299
+ "toolbar": [
300
+ "bold",
301
+ "italic",
302
+ "underline",
303
+ "h2",
304
+ "h3",
305
+ "numlist",
306
+ "bullist",
307
+ "blockquote",
308
+ "link",
309
+ "code",
310
+ "empty"
311
+ ]
312
+ },
313
+ "translations": [
314
+ { "language": "en-US", "translation": "Body" }
315
+ ],
316
+ "note": "Full project write-up",
317
+ "conditions": [
318
+ {
319
+ "name": "Required when published",
320
+ "rule": {
321
+ "_and": [{ "status": { "_eq": "published" } }]
322
+ },
323
+ "required": true
324
+ }
325
+ ]
326
+ },
327
+ "schema": {}
328
+ }
329
+ ]
330
+ }
331
+ ],
332
+ "relations": [
333
+ {
334
+ "collection": "projects",
335
+ "field": "featured_image",
336
+ "related_collection": "directus_files",
337
+ "meta": {
338
+ "many_collection": "projects",
339
+ "many_field": "featured_image",
340
+ "one_collection": "directus_files",
341
+ "one_field": null
342
+ },
343
+ "schema": {
344
+ "on_delete": "SET NULL"
345
+ }
346
+ }
347
+ ]
348
+ }