@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,43 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "name": "dkit Settings Public Read",
5
+ "icon": "public",
6
+ "description": "Public read for site settings incl. translations.",
7
+ "admin_access": false,
8
+ "app_access": false
9
+ }
10
+ ],
11
+ "permissions": [
12
+ {
13
+ "policy": "dkit Settings Public Read",
14
+ "collection": "site_settings",
15
+ "action": "read",
16
+ "fields": [
17
+ "*"
18
+ ]
19
+ },
20
+ {
21
+ "policy": "dkit Settings Public Read",
22
+ "collection": "site_settings_translations",
23
+ "action": "read",
24
+ "fields": [
25
+ "*"
26
+ ]
27
+ },
28
+ {
29
+ "policy": "dkit Settings Public Read",
30
+ "collection": "directus_files",
31
+ "action": "read",
32
+ "fields": [
33
+ "*"
34
+ ]
35
+ }
36
+ ],
37
+ "access": [
38
+ {
39
+ "role": "$public",
40
+ "policy": "dkit Settings Public Read"
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,158 @@
1
+ import {
2
+ directusAssetUrl,
3
+ directusFileId,
4
+ dkitQueryFailed,
5
+ getDirectus,
6
+ readSingleton,
7
+ } from "@/lib/dkit/client";
8
+ import { collections, defaultLocale } from "@/lib/dkit/config";
9
+ import {
10
+ pickTranslation,
11
+ resolveLocale,
12
+ } from "@/lib/dkit/i18n";
13
+ import type {
14
+ BuildSiteMetadataOptions,
15
+ GetSettingsOptions,
16
+ SiteMetadata,
17
+ SiteSettings,
18
+ SiteSettingsTranslation,
19
+ SiteSocialLink,
20
+ SiteSocialPlatform,
21
+ } from "./types.multilocale";
22
+
23
+ export type {
24
+ BuildSiteMetadataOptions,
25
+ DirectusFileRef,
26
+ GetSettingsOptions,
27
+ SiteFeatureFlags,
28
+ SiteMetadata,
29
+ SiteSettings,
30
+ SiteSettingsTranslation,
31
+ SiteSocialLink,
32
+ SiteSocialPlatform,
33
+ } from "./types.multilocale";
34
+
35
+ function flattenSettings(row: Record<string, unknown>, locale: string): SiteSettings {
36
+ const trans = pickTranslation(row.translations as SiteSettingsTranslation[] | undefined, locale);
37
+ // Settings singleton: fall back to defaultLocale for site brand chrome when requested locale missing
38
+ const defaultTrans = locale !== defaultLocale
39
+ ? pickTranslation(row.translations as SiteSettingsTranslation[] | undefined, defaultLocale)
40
+ : undefined;
41
+
42
+ return {
43
+ id: row.id as string,
44
+ site_name: trans?.site_name ?? defaultTrans?.site_name ?? "",
45
+ tagline: trans?.tagline ?? defaultTrans?.tagline ?? null,
46
+ logo: row.logo as SiteSettings["logo"],
47
+ favicon: row.favicon as SiteSettings["favicon"],
48
+ og_image: row.og_image as SiteSettings["og_image"],
49
+ contact_email: (row.contact_email as string | null) ?? null,
50
+ social_links: row.social_links as SiteSettings["social_links"],
51
+ maintenance_mode: (row.maintenance_mode as boolean | null) ?? null,
52
+ feature_flags: row.feature_flags as SiteSettings["feature_flags"],
53
+ };
54
+ }
55
+
56
+ const SETTINGS_FIELDS = [
57
+ "id", "logo", "favicon", "og_image", "contact_email",
58
+ "social_links", "maintenance_mode", "feature_flags",
59
+ { translations: ["id", "languages_code", "site_name", "tagline"] },
60
+ ] as const;
61
+
62
+ export const SOCIAL_PLATFORM_LABELS: Record<SiteSocialPlatform, string> = {
63
+ x: "X", github: "GitHub", linkedin: "LinkedIn", instagram: "Instagram",
64
+ facebook: "Facebook", youtube: "YouTube", bluesky: "Bluesky", mastodon: "Mastodon",
65
+ discord: "Discord", tiktok: "TikTok", threads: "Threads", email: "Email",
66
+ website: "Website", other: "Link",
67
+ };
68
+
69
+ export async function getSettings(_options: GetSettingsOptions = {}): Promise<SiteSettings | null> {
70
+ const client = getDirectus(); if (!client) return null;
71
+ if (!collections.site_settings) { dkitQueryFailed('collections.site_settings missing — re-run `dkit add settings`'); return null; }
72
+ const locale = await resolveLocale(_options.locale);
73
+ try {
74
+ const row = await client.request(readSingleton(collections.site_settings, { fields: [...SETTINGS_FIELDS] }));
75
+ return row ? flattenSettings(row as Record<string, unknown>, locale) : null;
76
+ } catch (err) { dkitQueryFailed(`getSettings failed`, err); return null; }
77
+ }
78
+
79
+ export async function getSetting<K extends keyof SiteSettings>(key: K, options: GetSettingsOptions = {}): Promise<SiteSettings[K] | undefined> {
80
+ const row = await getSettings(options); return row?.[key];
81
+ }
82
+
83
+ export async function isFeatureEnabled(flag: string): Promise<boolean> {
84
+ const row = await getSettings(); return Boolean(row?.feature_flags?.[flag]);
85
+ }
86
+
87
+ export async function isMaintenanceMode(): Promise<boolean> {
88
+ const row = await getSettings(); return Boolean(row?.maintenance_mode);
89
+ }
90
+
91
+ export function siteLogoUrl(settings: SiteSettings | null | undefined): string | null {
92
+ if (!settings) return null; const id = directusFileId(settings.logo); return id ? directusAssetUrl(id) : null;
93
+ }
94
+
95
+ export function siteFaviconUrl(settings: SiteSettings | null | undefined): string | null {
96
+ if (!settings) return null; const id = directusFileId(settings.favicon) ?? directusFileId(settings.logo); return id ? directusAssetUrl(id) : null;
97
+ }
98
+
99
+ export function siteOgImageUrl(settings: SiteSettings | null | undefined): string | null {
100
+ if (!settings) return null; const id = directusFileId(settings.og_image) ?? directusFileId(settings.logo); return id ? directusAssetUrl(id) : null;
101
+ }
102
+
103
+ export function siteSocialLinks(settings: SiteSettings | null | undefined): SiteSocialLink[] {
104
+ const rows = settings?.social_links; if (!Array.isArray(rows)) return [];
105
+ return rows.filter((row): row is SiteSocialLink => Boolean(row?.platform && typeof row.href === "string" && row.href.trim()));
106
+ }
107
+
108
+ export function socialLinkLabel(link: SiteSocialLink): string {
109
+ const o = link.label?.trim(); if (o) return o; return SOCIAL_PLATFORM_LABELS[link.platform] ?? SOCIAL_PLATFORM_LABELS.other;
110
+ }
111
+
112
+ export function isExternalSocialHref(href: string): boolean {
113
+ return /^https?:\/\//i.test(href) || href.startsWith("//") || href.startsWith("mailto:");
114
+ }
115
+
116
+ export function socialLinkProps(link: SiteSocialLink): { href: string; target?: "_blank"; rel?: string; "aria-label": string } {
117
+ const ext = isExternalSocialHref(link.href);
118
+ return { href: link.href, "aria-label": socialLinkLabel(link), ...(ext && !link.href.startsWith("mailto:") ? { target: "_blank" as const, rel: "noopener noreferrer" } : {}) };
119
+ }
120
+
121
+ function resolveSiteUrl(explicit?: string): string | undefined {
122
+ const raw = explicit || process.env.NEXT_PUBLIC_SITE_URL || process.env.SITE_URL || process.env.NUXT_PUBLIC_SITE_URL || undefined;
123
+ return raw?.replace(/\/$/, "") || undefined;
124
+ }
125
+
126
+ function joinSiteUrl(siteUrl: string | undefined, p = "/"): string | undefined {
127
+ if (!siteUrl) return undefined;
128
+ if (!p || p === "/") return `${siteUrl}/`;
129
+ const n = p.startsWith("/") ? p : `/${p}`;
130
+ return `${siteUrl}${n}`;
131
+ }
132
+
133
+ export function buildSiteMetadata(settings: SiteSettings | null | undefined, options: BuildSiteMetadataOptions = {}): SiteMetadata {
134
+ const siteName = settings?.site_name?.trim() || "Site";
135
+ const description = options.description === null ? undefined : (options.description?.trim() || settings?.tagline?.trim() || undefined);
136
+ const pageTitle = options.title?.trim() || siteName;
137
+ const ogTitle = options.absoluteTitle ? pageTitle : options.title ? `${pageTitle} — ${siteName}` : siteName;
138
+ const siteUrl = resolveSiteUrl(options.siteUrl);
139
+ const canonical = joinSiteUrl(siteUrl, options.path ?? "/");
140
+ const favicon = siteFaviconUrl(settings) ?? undefined;
141
+ const ogImage = siteOgImageUrl(settings);
142
+ const images = ogImage ? [{ url: ogImage }] : undefined;
143
+ const twitterImages = ogImage ? [ogImage] : undefined;
144
+ return {
145
+ title: options.absoluteTitle ? { absolute: pageTitle } : pageTitle,
146
+ ...(description ? { description } : {}),
147
+ ...(favicon ? { icons: { icon: favicon } } : {}),
148
+ ...(canonical ? { alternates: { canonical } } : {}),
149
+ openGraph: { title: ogTitle, ...(description ? { description } : {}), ...(canonical ? { url: canonical } : {}), siteName, type: options.type ?? "website", ...(images ? { images } : {}) },
150
+ twitter: { card: ogImage ? "summary_large_image" : "summary", title: ogTitle, ...(description ? { description } : {}), ...(twitterImages ? { images: twitterImages } : {}) },
151
+ ...(options.noIndex ? { robots: { index: false, follow: false } } : { robots: { index: true, follow: true } }),
152
+ };
153
+ }
154
+
155
+ export async function getSiteMetadata(options: BuildSiteMetadataOptions & { locale?: string } = {}): Promise<SiteMetadata> {
156
+ const settings = await getSettings({ locale: options.locale });
157
+ return buildSiteMetadata(settings, options);
158
+ }
@@ -0,0 +1,259 @@
1
+ import {
2
+ directusAssetUrl,
3
+ directusFileId,
4
+ dkitQueryFailed,
5
+ getDirectus,
6
+ readSingleton,
7
+ } from "@/lib/dkit/client";
8
+ import { collections } from "@/lib/dkit/config";
9
+ import type {
10
+ BuildSiteMetadataOptions,
11
+ GetSettingsOptions,
12
+ SiteMetadata,
13
+ SiteSettings,
14
+ SiteSocialLink,
15
+ SiteSocialPlatform,
16
+ } from "./types";
17
+
18
+ export type {
19
+ BuildSiteMetadataOptions,
20
+ DirectusFileRef,
21
+ GetSettingsOptions,
22
+ SiteFeatureFlags,
23
+ SiteMetadata,
24
+ SiteSettings,
25
+ SiteSocialLink,
26
+ SiteSocialPlatform,
27
+ } from "./types";
28
+
29
+ const SETTINGS_FIELDS = [
30
+ "id",
31
+ "site_name",
32
+ "tagline",
33
+ "logo",
34
+ "favicon",
35
+ "og_image",
36
+ "contact_email",
37
+ "social_links",
38
+ "maintenance_mode",
39
+ "feature_flags",
40
+ ] as const;
41
+
42
+ /** Display labels for social platform keys. */
43
+ export const SOCIAL_PLATFORM_LABELS: Record<SiteSocialPlatform, string> = {
44
+ x: "X",
45
+ github: "GitHub",
46
+ linkedin: "LinkedIn",
47
+ instagram: "Instagram",
48
+ facebook: "Facebook",
49
+ youtube: "YouTube",
50
+ bluesky: "Bluesky",
51
+ mastodon: "Mastodon",
52
+ discord: "Discord",
53
+ tiktok: "TikTok",
54
+ threads: "Threads",
55
+ email: "Email",
56
+ website: "Website",
57
+ other: "Link",
58
+ };
59
+
60
+ /**
61
+ * Read the site settings singleton.
62
+ * Soft-fails to null when Directus is down or the collection is missing.
63
+ */
64
+ export async function getSettings(
65
+ _options: GetSettingsOptions = {},
66
+ ): Promise<SiteSettings | null> {
67
+ const client = getDirectus();
68
+ if (!client) return null;
69
+ if (!collections.site_settings) {
70
+ dkitQueryFailed(
71
+ 'collections.site_settings missing from lib/dkit/config — re-run `dkit add settings`',
72
+ );
73
+ return null;
74
+ }
75
+ try {
76
+ return await client.request(
77
+ readSingleton(collections.site_settings, {
78
+ fields: [...SETTINGS_FIELDS],
79
+ }),
80
+ );
81
+ } catch (err) {
82
+ dkitQueryFailed(
83
+ `getSettings failed (collection=${collections.site_settings})`,
84
+ err,
85
+ );
86
+ return null;
87
+ }
88
+ }
89
+
90
+ /** Typed field accessor — returns undefined when settings are unavailable. */
91
+ export async function getSetting<K extends keyof SiteSettings>(
92
+ key: K,
93
+ ): Promise<SiteSettings[K] | undefined> {
94
+ const row = await getSettings();
95
+ return row?.[key];
96
+ }
97
+
98
+ /** Feature flag lookup — missing flags are false. */
99
+ export async function isFeatureEnabled(flag: string): Promise<boolean> {
100
+ const row = await getSettings();
101
+ return Boolean(row?.feature_flags?.[flag]);
102
+ }
103
+
104
+ /** True when settings.maintenance_mode is enabled. Soft-fails to false. */
105
+ export async function isMaintenanceMode(): Promise<boolean> {
106
+ const row = await getSettings();
107
+ return Boolean(row?.maintenance_mode);
108
+ }
109
+
110
+ export function siteLogoUrl(
111
+ settings: SiteSettings | null | undefined,
112
+ ): string | null {
113
+ if (!settings) return null;
114
+ const id = directusFileId(settings.logo);
115
+ return id ? directusAssetUrl(id) : null;
116
+ }
117
+
118
+ export function siteFaviconUrl(
119
+ settings: SiteSettings | null | undefined,
120
+ ): string | null {
121
+ if (!settings) return null;
122
+ const id = directusFileId(settings.favicon) ?? directusFileId(settings.logo);
123
+ return id ? directusAssetUrl(id) : null;
124
+ }
125
+
126
+ export function siteOgImageUrl(
127
+ settings: SiteSettings | null | undefined,
128
+ ): string | null {
129
+ if (!settings) return null;
130
+ const id = directusFileId(settings.og_image) ?? directusFileId(settings.logo);
131
+ return id ? directusAssetUrl(id) : null;
132
+ }
133
+
134
+ /** Normalized social links from settings (skips incomplete rows). */
135
+ export function siteSocialLinks(
136
+ settings: SiteSettings | null | undefined,
137
+ ): SiteSocialLink[] {
138
+ const rows = settings?.social_links;
139
+ if (!Array.isArray(rows)) return [];
140
+ return rows.filter(
141
+ (row): row is SiteSocialLink =>
142
+ Boolean(row?.platform && typeof row.href === "string" && row.href.trim()),
143
+ );
144
+ }
145
+
146
+ export function socialLinkLabel(link: SiteSocialLink): string {
147
+ const override = link.label?.trim();
148
+ if (override) return override;
149
+ return SOCIAL_PLATFORM_LABELS[link.platform] ?? SOCIAL_PLATFORM_LABELS.other;
150
+ }
151
+
152
+ export function isExternalSocialHref(href: string): boolean {
153
+ return (
154
+ /^https?:\/\//i.test(href) ||
155
+ href.startsWith("//") ||
156
+ href.startsWith("mailto:")
157
+ );
158
+ }
159
+
160
+ export function socialLinkProps(link: SiteSocialLink): {
161
+ href: string;
162
+ target?: "_blank";
163
+ rel?: string;
164
+ "aria-label": string;
165
+ } {
166
+ const external = isExternalSocialHref(link.href);
167
+ return {
168
+ href: link.href,
169
+ "aria-label": socialLinkLabel(link),
170
+ ...(external && !link.href.startsWith("mailto:")
171
+ ? { target: "_blank" as const, rel: "noopener noreferrer" }
172
+ : {}),
173
+ };
174
+ }
175
+
176
+ function resolveSiteUrl(explicit?: string): string | undefined {
177
+ const raw =
178
+ explicit ||
179
+ process.env.NEXT_PUBLIC_SITE_URL ||
180
+ process.env.SITE_URL ||
181
+ process.env.NUXT_PUBLIC_SITE_URL ||
182
+ undefined;
183
+ return raw?.replace(/\/$/, "") || undefined;
184
+ }
185
+
186
+ function joinSiteUrl(siteUrl: string | undefined, path = "/"): string | undefined {
187
+ if (!siteUrl) return undefined;
188
+ if (!path || path === "/") return `${siteUrl}/`;
189
+ const normalized = path.startsWith("/") ? path : `/${path}`;
190
+ return `${siteUrl}${normalized}`;
191
+ }
192
+
193
+ /**
194
+ * Build Next-compatible metadata from a settings row.
195
+ * Use in `generateMetadata` / root layout:
196
+ *
197
+ * ```ts
198
+ * export async function generateMetadata() {
199
+ * return getSiteMetadata({ path: "/" });
200
+ * }
201
+ * ```
202
+ */
203
+ export function buildSiteMetadata(
204
+ settings: SiteSettings | null | undefined,
205
+ options: BuildSiteMetadataOptions = {},
206
+ ): SiteMetadata {
207
+ const siteName = settings?.site_name?.trim() || "Site";
208
+ const description =
209
+ options.description === null
210
+ ? undefined
211
+ : (options.description?.trim() ||
212
+ settings?.tagline?.trim() ||
213
+ undefined);
214
+ const pageTitle = options.title?.trim() || siteName;
215
+ const ogTitle = options.absoluteTitle
216
+ ? pageTitle
217
+ : options.title
218
+ ? `${pageTitle} — ${siteName}`
219
+ : siteName;
220
+
221
+ const siteUrl = resolveSiteUrl(options.siteUrl);
222
+ const canonical = joinSiteUrl(siteUrl, options.path ?? "/");
223
+ const favicon = siteFaviconUrl(settings) ?? undefined;
224
+ const ogImage = siteOgImageUrl(settings);
225
+ const images = ogImage ? [{ url: ogImage }] : undefined;
226
+ const twitterImages = ogImage ? [ogImage] : undefined;
227
+
228
+ return {
229
+ title: options.absoluteTitle ? { absolute: pageTitle } : pageTitle,
230
+ ...(description ? { description } : {}),
231
+ ...(favicon ? { icons: { icon: favicon } } : {}),
232
+ ...(canonical ? { alternates: { canonical } } : {}),
233
+ openGraph: {
234
+ title: ogTitle,
235
+ ...(description ? { description } : {}),
236
+ ...(canonical ? { url: canonical } : {}),
237
+ siteName,
238
+ type: options.type ?? "website",
239
+ ...(images ? { images } : {}),
240
+ },
241
+ twitter: {
242
+ card: ogImage ? "summary_large_image" : "summary",
243
+ title: ogTitle,
244
+ ...(description ? { description } : {}),
245
+ ...(twitterImages ? { images: twitterImages } : {}),
246
+ },
247
+ ...(options.noIndex
248
+ ? { robots: { index: false, follow: false } }
249
+ : { robots: { index: true, follow: true } }),
250
+ };
251
+ }
252
+
253
+ /** Fetch settings and build site metadata in one call. */
254
+ export async function getSiteMetadata(
255
+ options: BuildSiteMetadataOptions = {},
256
+ ): Promise<SiteMetadata> {
257
+ const settings = await getSettings();
258
+ return buildSiteMetadata(settings, options);
259
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "type": "dkit:module",
3
+ "id": "settings",
4
+ "title": "Settings",
5
+ "description": "Site brand and config singleton — name, logo, contact, socials, feature flags",
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
+ "site-logo",
21
+ "site-brand",
22
+ "social-links",
23
+ "maintenance-gate"
24
+ ],
25
+ "collections": [
26
+ "site",
27
+ "site_settings"
28
+ ],
29
+ "multilocale": {
30
+ "supported": true,
31
+ "mode": "translations"
32
+ }
33
+ }