@kurbo/dkit 0.5.0 → 0.5.1

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 (96) hide show
  1. package/dist/bin.js +119 -26
  2. package/dist/bin.js.map +1 -1
  3. package/package.json +1 -1
  4. package/vendor/registry/blocks/blog-detail/ui/minimal/next/blog-detail.tsx +0 -1
  5. package/vendor/registry/blocks/blog-detail/ui/shadcn/next/blog-detail.tsx +0 -1
  6. package/vendor/registry/blocks/blog-list/ui/minimal/next/blog-list.tsx +0 -1
  7. package/vendor/registry/blocks/blog-list/ui/shadcn/next/blog-list.tsx +0 -1
  8. package/vendor/registry/blocks/blog-list-cards/ui/minimal/next/blog-list-cards.tsx +0 -1
  9. package/vendor/registry/blocks/blog-list-cards/ui/shadcn/next/blog-list-cards.tsx +0 -1
  10. package/vendor/registry/blocks/booking-form-ui/ui/minimal/next/booking-form.tsx +0 -1
  11. package/vendor/registry/blocks/booking-form-ui/ui/shadcn/next/booking-form.tsx +0 -1
  12. package/vendor/registry/blocks/contact-form-ui/ui/minimal/next/contact-form.tsx +0 -1
  13. package/vendor/registry/blocks/contact-form-ui/ui/shadcn/next/contact-form.tsx +0 -1
  14. package/vendor/registry/blocks/faq-list/ui/minimal/next/faq-list.tsx +0 -1
  15. package/vendor/registry/blocks/faq-list/ui/shadcn/next/faq-list.tsx +0 -1
  16. package/vendor/registry/blocks/page-detail/ui/minimal/next/page-detail.tsx +0 -1
  17. package/vendor/registry/blocks/page-detail/ui/shadcn/next/page-detail.tsx +0 -1
  18. package/vendor/registry/blocks/project-detail/ui/minimal/next/project-detail.tsx +0 -1
  19. package/vendor/registry/blocks/project-detail/ui/shadcn/next/project-detail.tsx +0 -1
  20. package/vendor/registry/blocks/project-list/ui/minimal/next/project-list.tsx +0 -1
  21. package/vendor/registry/blocks/project-list/ui/shadcn/next/project-list.tsx +0 -1
  22. package/vendor/registry/blocks/project-list-cards/ui/minimal/next/project-list-cards.tsx +0 -1
  23. package/vendor/registry/blocks/project-list-cards/ui/shadcn/next/project-list-cards.tsx +0 -1
  24. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel-client.tsx +0 -4
  25. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel.tsx +0 -1
  26. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel-client.tsx +0 -1
  27. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel.tsx +0 -1
  28. package/vendor/registry/blocks/service-detail/ui/minimal/next/service-detail.tsx +0 -1
  29. package/vendor/registry/blocks/service-detail/ui/shadcn/next/service-detail.tsx +0 -1
  30. package/vendor/registry/blocks/service-list/ui/minimal/next/service-list.tsx +0 -1
  31. package/vendor/registry/blocks/service-list/ui/shadcn/next/service-list.tsx +0 -1
  32. package/vendor/registry/blocks/service-list-cards/ui/minimal/next/service-list-cards.tsx +0 -1
  33. package/vendor/registry/blocks/service-list-cards/ui/shadcn/next/service-list-cards.tsx +0 -1
  34. package/vendor/registry/blocks/social-links/ui/minimal/next/social-links.tsx +0 -1
  35. package/vendor/registry/blocks/social-links/ui/shadcn/next/social-links.tsx +0 -1
  36. package/vendor/registry/blocks/team-detail/ui/minimal/next/team-detail.tsx +0 -1
  37. package/vendor/registry/blocks/team-detail/ui/shadcn/next/team-detail.tsx +0 -1
  38. package/vendor/registry/blocks/team-list/ui/minimal/next/team-list.tsx +0 -1
  39. package/vendor/registry/blocks/team-list/ui/shadcn/next/team-list.tsx +0 -1
  40. package/vendor/registry/blocks/team-list-cards/ui/minimal/next/team-list-cards.tsx +0 -1
  41. package/vendor/registry/blocks/team-list-cards/ui/shadcn/next/team-list-cards.tsx +0 -1
  42. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel-client.tsx +0 -4
  43. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel.tsx +0 -1
  44. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel-client.tsx +0 -1
  45. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel.tsx +0 -1
  46. package/vendor/registry/blocks/testimonials-list/ui/minimal/next/testimonials-list.tsx +0 -1
  47. package/vendor/registry/blocks/testimonials-list/ui/shadcn/next/testimonials-list.tsx +0 -1
  48. package/vendor/registry/blocks/testimonials-list-cards/ui/minimal/next/testimonials-list-cards.tsx +0 -1
  49. package/vendor/registry/blocks/testimonials-list-cards/ui/shadcn/next/testimonials-list-cards.tsx +0 -1
  50. package/vendor/registry/modules/blog/lib.multilocale.ts +124 -129
  51. package/vendor/registry/modules/blog/lib.ts +12 -9
  52. package/vendor/registry/modules/blog/services/seed.json +1 -1
  53. package/vendor/registry/modules/blog/services/seed.multilocale.json +1 -1
  54. package/vendor/registry/modules/blog/types.multilocale.ts +41 -12
  55. package/vendor/registry/modules/blog/types.ts +8 -6
  56. package/vendor/registry/modules/faq/lib.multilocale.ts +30 -30
  57. package/vendor/registry/modules/faq/lib.ts +4 -5
  58. package/vendor/registry/modules/faq/types.multilocale.ts +13 -2
  59. package/vendor/registry/modules/faq/types.ts +4 -2
  60. package/vendor/registry/modules/navigation/lib.multilocale.ts +207 -76
  61. package/vendor/registry/modules/navigation/lib.ts +18 -17
  62. package/vendor/registry/modules/navigation/types.multilocale.ts +24 -4
  63. package/vendor/registry/modules/navigation/types.ts +6 -4
  64. package/vendor/registry/modules/pages/lib.multilocale.ts +34 -39
  65. package/vendor/registry/modules/pages/lib.ts +4 -3
  66. package/vendor/registry/modules/pages/types.multilocale.ts +14 -3
  67. package/vendor/registry/modules/pages/types.ts +5 -3
  68. package/vendor/registry/modules/projects/lib.multilocale.ts +149 -65
  69. package/vendor/registry/modules/projects/lib.ts +6 -6
  70. package/vendor/registry/modules/projects/services/seed.json +2 -2
  71. package/vendor/registry/modules/projects/services/seed.multilocale.json +2 -2
  72. package/vendor/registry/modules/projects/types.multilocale.ts +15 -3
  73. package/vendor/registry/modules/projects/types.ts +5 -3
  74. package/vendor/registry/modules/services/lib.multilocale.ts +143 -63
  75. package/vendor/registry/modules/services/lib.ts +6 -6
  76. package/vendor/registry/modules/services/services/seed.json +4 -4
  77. package/vendor/registry/modules/services/services/seed.multilocale.json +2 -2
  78. package/vendor/registry/modules/services/types.multilocale.ts +13 -3
  79. package/vendor/registry/modules/services/types.ts +5 -3
  80. package/vendor/registry/modules/settings/lib.multilocale.ts +159 -57
  81. package/vendor/registry/modules/settings/types.multilocale.ts +15 -0
  82. package/vendor/registry/modules/settings/types.ts +2 -2
  83. package/vendor/registry/modules/team/lib.multilocale.ts +116 -49
  84. package/vendor/registry/modules/team/lib.ts +4 -3
  85. package/vendor/registry/modules/team/services/seed.json +4 -4
  86. package/vendor/registry/modules/team/services/seed.multilocale.json +2 -2
  87. package/vendor/registry/modules/team/types.multilocale.ts +16 -3
  88. package/vendor/registry/modules/team/types.ts +5 -3
  89. package/vendor/registry/modules/testimonials/lib.multilocale.ts +82 -50
  90. package/vendor/registry/modules/testimonials/services/seed.json +4 -4
  91. package/vendor/registry/modules/testimonials/services/seed.multilocale.json +2 -2
  92. package/vendor/registry/modules/testimonials/types.multilocale.ts +14 -2
  93. package/vendor/registry/modules/testimonials/types.ts +4 -2
  94. package/vendor/registry/shared/helpers.ts +9 -3
  95. package/vendor/registry/shared/i18n.ts +84 -12
  96. package/vendor/registry/shared/prose.css +1 -1
@@ -6,16 +6,13 @@ import {
6
6
  readSingleton,
7
7
  } from "@/lib/dkit/client";
8
8
  import { collections, defaultLocale } from "@/lib/dkit/config";
9
- import {
10
- pickTranslation,
11
- resolveLocale,
12
- } from "@/lib/dkit/i18n";
9
+ import { pickTranslation, resolveLocale } from "@/lib/dkit/i18n";
13
10
  import type {
14
11
  BuildSiteMetadataOptions,
15
12
  GetSettingsOptions,
16
13
  SiteMetadata,
17
14
  SiteSettings,
18
- SiteSettingsTranslation,
15
+ SiteSettingsRow,
19
16
  SiteSocialLink,
20
17
  SiteSocialPlatform,
21
18
  } from "./types.multilocale";
@@ -27,99 +24,178 @@ export type {
27
24
  SiteFeatureFlags,
28
25
  SiteMetadata,
29
26
  SiteSettings,
27
+ SiteSettingsRow,
30
28
  SiteSettingsTranslation,
31
29
  SiteSocialLink,
32
30
  SiteSocialPlatform,
33
31
  } from "./types.multilocale";
34
32
 
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
-
33
+ function flattenSettings(row: SiteSettingsRow, locale: string): SiteSettings {
34
+ const trans = pickTranslation(row.translations, locale);
35
+ // Settings singleton: fall back per-field to defaultLocale so chrome never blanks
36
+ const defaultTrans =
37
+ locale !== defaultLocale
38
+ ? pickTranslation(row.translations, defaultLocale)
39
+ : undefined;
40
+
42
41
  return {
43
- id: row.id as string,
42
+ id: row.id,
44
43
  site_name: trans?.site_name ?? defaultTrans?.site_name ?? "",
45
44
  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"],
45
+ logo: row.logo,
46
+ favicon: row.favicon,
47
+ og_image: row.og_image,
48
+ contact_email: row.contact_email ?? null,
49
+ social_links: row.social_links,
50
+ maintenance_mode: row.maintenance_mode ?? null,
51
+ feature_flags: row.feature_flags,
53
52
  };
54
53
  }
55
54
 
56
55
  const SETTINGS_FIELDS = [
57
- "id", "logo", "favicon", "og_image", "contact_email",
58
- "social_links", "maintenance_mode", "feature_flags",
56
+ "id",
57
+ "logo",
58
+ "favicon",
59
+ "og_image",
60
+ "contact_email",
61
+ "social_links",
62
+ "maintenance_mode",
63
+ "feature_flags",
59
64
  { translations: ["id", "languages_code", "site_name", "tagline"] },
60
65
  ] as const;
61
66
 
62
67
  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",
68
+ x: "X",
69
+ github: "GitHub",
70
+ linkedin: "LinkedIn",
71
+ instagram: "Instagram",
72
+ facebook: "Facebook",
73
+ youtube: "YouTube",
74
+ bluesky: "Bluesky",
75
+ mastodon: "Mastodon",
76
+ discord: "Discord",
77
+ tiktok: "TikTok",
78
+ threads: "Threads",
79
+ email: "Email",
80
+ website: "Website",
81
+ other: "Link",
67
82
  };
68
83
 
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; }
84
+ export async function getSettings(
85
+ _options: GetSettingsOptions = {},
86
+ ): Promise<SiteSettings | null> {
87
+ const client = getDirectus();
88
+ if (!client) return null;
89
+ if (!collections.site_settings) {
90
+ dkitQueryFailed(
91
+ "collections.site_settings missing — re-run `dkit add settings`",
92
+ );
93
+ return null;
94
+ }
72
95
  const locale = await resolveLocale(_options.locale);
73
96
  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; }
97
+ const row = await client.request(
98
+ readSingleton(collections.site_settings, { fields: [...SETTINGS_FIELDS] }),
99
+ );
100
+ return row ? flattenSettings(row as SiteSettingsRow, locale) : null;
101
+ } catch (err) {
102
+ dkitQueryFailed(`getSettings failed`, err);
103
+ return null;
104
+ }
77
105
  }
78
106
 
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];
107
+ export async function getSetting<K extends keyof SiteSettings>(
108
+ key: K,
109
+ options: GetSettingsOptions = {},
110
+ ): Promise<SiteSettings[K] | undefined> {
111
+ const row = await getSettings(options);
112
+ return row?.[key];
81
113
  }
82
114
 
83
115
  export async function isFeatureEnabled(flag: string): Promise<boolean> {
84
- const row = await getSettings(); return Boolean(row?.feature_flags?.[flag]);
116
+ const row = await getSettings();
117
+ return Boolean(row?.feature_flags?.[flag]);
85
118
  }
86
119
 
87
120
  export async function isMaintenanceMode(): Promise<boolean> {
88
- const row = await getSettings(); return Boolean(row?.maintenance_mode);
121
+ const row = await getSettings();
122
+ return Boolean(row?.maintenance_mode);
89
123
  }
90
124
 
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;
125
+ export function siteLogoUrl(
126
+ settings: SiteSettings | null | undefined,
127
+ ): string | null {
128
+ if (!settings) return null;
129
+ const id = directusFileId(settings.logo);
130
+ return id ? directusAssetUrl(id) : null;
93
131
  }
94
132
 
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;
133
+ export function siteFaviconUrl(
134
+ settings: SiteSettings | null | undefined,
135
+ ): string | null {
136
+ if (!settings) return null;
137
+ const id =
138
+ directusFileId(settings.favicon) ?? directusFileId(settings.logo);
139
+ return id ? directusAssetUrl(id) : null;
97
140
  }
98
141
 
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;
142
+ export function siteOgImageUrl(
143
+ settings: SiteSettings | null | undefined,
144
+ ): string | null {
145
+ if (!settings) return null;
146
+ const id =
147
+ directusFileId(settings.og_image) ?? directusFileId(settings.logo);
148
+ return id ? directusAssetUrl(id) : null;
101
149
  }
102
150
 
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()));
151
+ export function siteSocialLinks(
152
+ settings: SiteSettings | null | undefined,
153
+ ): SiteSocialLink[] {
154
+ const rows = settings?.social_links;
155
+ if (!Array.isArray(rows)) return [];
156
+ return rows.filter(
157
+ (row): row is SiteSocialLink =>
158
+ Boolean(row?.platform && typeof row.href === "string" && row.href.trim()),
159
+ );
106
160
  }
107
161
 
108
162
  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;
163
+ const o = link.label?.trim();
164
+ if (o) return o;
165
+ return SOCIAL_PLATFORM_LABELS[link.platform] ?? SOCIAL_PLATFORM_LABELS.other;
110
166
  }
111
167
 
112
168
  export function isExternalSocialHref(href: string): boolean {
113
- return /^https?:\/\//i.test(href) || href.startsWith("//") || href.startsWith("mailto:");
169
+ return (
170
+ /^https?:\/\//i.test(href) ||
171
+ href.startsWith("//") ||
172
+ href.startsWith("mailto:")
173
+ );
114
174
  }
115
175
 
116
- export function socialLinkProps(link: SiteSocialLink): { href: string; target?: "_blank"; rel?: string; "aria-label": string } {
176
+ export function socialLinkProps(link: SiteSocialLink): {
177
+ href: string;
178
+ target?: "_blank";
179
+ rel?: string;
180
+ "aria-label": string;
181
+ } {
117
182
  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" } : {}) };
183
+ return {
184
+ href: link.href,
185
+ "aria-label": socialLinkLabel(link),
186
+ ...(ext && !link.href.startsWith("mailto:")
187
+ ? { target: "_blank" as const, rel: "noopener noreferrer" }
188
+ : {}),
189
+ };
119
190
  }
120
191
 
121
192
  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;
193
+ const raw =
194
+ explicit ||
195
+ process.env.NEXT_PUBLIC_SITE_URL ||
196
+ process.env.SITE_URL ||
197
+ process.env.NUXT_PUBLIC_SITE_URL ||
198
+ undefined;
123
199
  return raw?.replace(/\/$/, "") || undefined;
124
200
  }
125
201
 
@@ -130,11 +206,21 @@ function joinSiteUrl(siteUrl: string | undefined, p = "/"): string | undefined {
130
206
  return `${siteUrl}${n}`;
131
207
  }
132
208
 
133
- export function buildSiteMetadata(settings: SiteSettings | null | undefined, options: BuildSiteMetadataOptions = {}): SiteMetadata {
209
+ export function buildSiteMetadata(
210
+ settings: SiteSettings | null | undefined,
211
+ options: BuildSiteMetadataOptions = {},
212
+ ): SiteMetadata {
134
213
  const siteName = settings?.site_name?.trim() || "Site";
135
- const description = options.description === null ? undefined : (options.description?.trim() || settings?.tagline?.trim() || undefined);
214
+ const description =
215
+ options.description === null
216
+ ? undefined
217
+ : options.description?.trim() || settings?.tagline?.trim() || undefined;
136
218
  const pageTitle = options.title?.trim() || siteName;
137
- const ogTitle = options.absoluteTitle ? pageTitle : options.title ? `${pageTitle} — ${siteName}` : siteName;
219
+ const ogTitle = options.absoluteTitle
220
+ ? pageTitle
221
+ : options.title
222
+ ? `${pageTitle} — ${siteName}`
223
+ : siteName;
138
224
  const siteUrl = resolveSiteUrl(options.siteUrl);
139
225
  const canonical = joinSiteUrl(siteUrl, options.path ?? "/");
140
226
  const favicon = siteFaviconUrl(settings) ?? undefined;
@@ -146,13 +232,29 @@ export function buildSiteMetadata(settings: SiteSettings | null | undefined, opt
146
232
  ...(description ? { description } : {}),
147
233
  ...(favicon ? { icons: { icon: favicon } } : {}),
148
234
  ...(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 } }),
235
+ openGraph: {
236
+ title: ogTitle,
237
+ ...(description ? { description } : {}),
238
+ ...(canonical ? { url: canonical } : {}),
239
+ siteName,
240
+ type: options.type ?? "website",
241
+ ...(images ? { images } : {}),
242
+ },
243
+ twitter: {
244
+ card: ogImage ? "summary_large_image" : "summary",
245
+ title: ogTitle,
246
+ ...(description ? { description } : {}),
247
+ ...(twitterImages ? { images: twitterImages } : {}),
248
+ },
249
+ ...(options.noIndex
250
+ ? { robots: { index: false, follow: false } }
251
+ : { robots: { index: true, follow: true } }),
152
252
  };
153
253
  }
154
254
 
155
- export async function getSiteMetadata(options: BuildSiteMetadataOptions & { locale?: string } = {}): Promise<SiteMetadata> {
255
+ export async function getSiteMetadata(
256
+ options: BuildSiteMetadataOptions & { locale?: string } = {},
257
+ ): Promise<SiteMetadata> {
156
258
  const settings = await getSettings({ locale: options.locale });
157
259
  return buildSiteMetadata(settings, options);
158
260
  }
@@ -21,6 +21,19 @@ export type SiteSocialLink = {
21
21
 
22
22
  export type SiteFeatureFlags = Record<string, boolean>;
23
23
 
24
+ /** Wire singleton shape (Directus / DkitSchema when multilocales). */
25
+ export type SiteSettingsRow = {
26
+ id: string;
27
+ logo?: string | DirectusFileRef | null;
28
+ favicon?: string | DirectusFileRef | null;
29
+ og_image?: string | DirectusFileRef | null;
30
+ contact_email?: string | null;
31
+ social_links?: SiteSocialLink[] | null;
32
+ maintenance_mode?: boolean | null;
33
+ feature_flags?: SiteFeatureFlags | null;
34
+ translations?: SiteSettingsTranslation[] | null;
35
+ };
36
+
24
37
  export type SiteSettings = {
25
38
  id: string;
26
39
  site_name: string;
@@ -35,7 +48,9 @@ export type SiteSettings = {
35
48
  };
36
49
 
37
50
  export type GetSettingsOptions = {
51
+ /** Ignored — settings is a singleton. Present for API consistency with other getters. */
38
52
  status?: string | null;
53
+ /** Override resolved locale (BCP 47 code). */
39
54
  locale?: string;
40
55
  };
41
56
 
@@ -42,7 +42,7 @@ export type SiteSettings = {
42
42
  };
43
43
 
44
44
  export type GetSettingsOptions = {
45
- /** Unused today — reserved for future draft/preview. */
45
+ /** Ignored — settings is a singleton. Present for API consistency with other getters. */
46
46
  status?: string | null;
47
47
  };
48
48
 
@@ -50,7 +50,7 @@ export type GetSettingsOptions = {
50
50
  export type BuildSiteMetadataOptions = {
51
51
  /**
52
52
  * Absolute site origin (`https://example.com`).
53
- * Falls back to `NEXT_PUBLIC_SITE_URL` / `SITE_URL` / `NUXT_PUBLIC_SITE_URL`.
53
+ * Falls back to `NEXT_PUBLIC_SITE_URL` / `SITE_URL`.
54
54
  */
55
55
  siteUrl?: string;
56
56
  /** Page path appended to siteUrl for canonical / OG url (default `/`). */
@@ -9,31 +9,60 @@ import {
9
9
  import { collections } from "@/lib/dkit/config";
10
10
  import { queryLimit, statusFilter } from "@/lib/dkit/helpers";
11
11
  import {
12
- pickTranslation,
13
12
  resolveLocale,
14
13
  translationsDeepFilter,
14
+ withLocale,
15
15
  } from "@/lib/dkit/i18n";
16
- import type { GetTeamMemberBySlugOptions, GetTeamMembersOptions, TeamMember, TeamMemberTranslation } from "./types.multilocale";
16
+ import type {
17
+ GetTeamMemberBySlugOptions,
18
+ GetTeamMembersOptions,
19
+ TeamMember,
20
+ TeamMemberRow,
21
+ } from "./types.multilocale";
17
22
 
18
- export type { DirectusFileRef, GetTeamMemberBySlugOptions, GetTeamMembersOptions, TeamMember, TeamMemberTranslation } from "./types.multilocale";
23
+ export type {
24
+ DirectusFileRef,
25
+ GetTeamMemberBySlugOptions,
26
+ GetTeamMembersOptions,
27
+ TeamMember,
28
+ TeamMemberRow,
29
+ TeamMemberTranslation,
30
+ } from "./types.multilocale";
19
31
 
20
- function flattenTeamMember(row: Record<string, unknown>, locale: string): TeamMember {
21
- const trans = pickTranslation(row.translations as TeamMemberTranslation[] | undefined, locale);
22
- return {
23
- id: row.id as string,
24
- status: row.status as TeamMember["status"],
25
- name: row.name as string,
26
- slug: row.slug as string,
27
- role: trans?.role ?? null,
28
- bio: trans?.bio ?? null,
29
- photo: row.photo as TeamMember["photo"],
30
- email: (row.email as string | null) ?? null,
31
- sort: (row.sort as number | null) ?? null,
32
- };
32
+ function flattenTeamMember(row: TeamMemberRow, locale: string): TeamMember {
33
+ return (
34
+ withLocale(row, locale, (r, t) => ({
35
+ id: r.id,
36
+ status: r.status,
37
+ name: r.name,
38
+ slug: r.slug,
39
+ role: t?.role ?? null,
40
+ bio: t?.bio ?? null,
41
+ photo: r.photo,
42
+ email: r.email ?? null,
43
+ sort: r.sort ?? null,
44
+ })) ?? {
45
+ id: row.id,
46
+ status: row.status,
47
+ name: row.name,
48
+ slug: row.slug,
49
+ role: null,
50
+ bio: null,
51
+ photo: row.photo,
52
+ email: row.email ?? null,
53
+ sort: row.sort ?? null,
54
+ }
55
+ );
33
56
  }
34
57
 
35
58
  const TEAM_MEMBER_FIELDS = [
36
- "id", "status", "name", "slug", "photo", "email", "sort",
59
+ "id",
60
+ "status",
61
+ "name",
62
+ "slug",
63
+ "photo",
64
+ "email",
65
+ "sort",
37
66
  { translations: ["id", "languages_code", "role", "bio"] },
38
67
  ] as const;
39
68
 
@@ -42,47 +71,85 @@ export function teamMemberPhotoUrl(member: TeamMember): string | null {
42
71
  return id ? directusAssetUrl(id) : null;
43
72
  }
44
73
 
45
- export async function getTeamMembers(options: GetTeamMembersOptions = {}): Promise<TeamMember[]> {
46
- const client = getDirectus(); if (!client) return [];
47
- if (!collections.team_members) { dkitQueryFailed('collections.team_members missing — re-run `dkit add team`'); return []; }
74
+ export async function getTeamMembers(
75
+ options: GetTeamMembersOptions = {},
76
+ ): Promise<TeamMember[]> {
77
+ const client = getDirectus();
78
+ if (!client) return [];
79
+ if (!collections.team_members) {
80
+ dkitQueryFailed("collections.team_members missing — re-run `dkit add team`");
81
+ return [];
82
+ }
48
83
  const locale = await resolveLocale(options.locale);
49
- const status = statusFilter(options.status); const limit = queryLimit(options.limit);
84
+ const status = statusFilter(options.status);
85
+ const limit = queryLimit(options.limit);
50
86
  try {
51
- const rows = await client.request(readItems(collections.team_members, {
52
- filter: status,
53
- deep: translationsDeepFilter(locale),
54
- fields: [...TEAM_MEMBER_FIELDS], sort: options.sort ?? ["sort", "name"],
55
- ...(limit !== undefined ? { limit } : {}),
56
- }));
57
- return (rows as Record<string, unknown>[]).map((r) => flattenTeamMember(r, locale));
58
- } catch (err) { dkitQueryFailed(`getTeamMembers failed`, err); return []; }
87
+ const rows = await client.request(
88
+ readItems(collections.team_members, {
89
+ filter: status,
90
+ deep: translationsDeepFilter(locale),
91
+ fields: [...TEAM_MEMBER_FIELDS],
92
+ sort: options.sort ?? ["sort", "name"],
93
+ ...(limit !== undefined ? { limit } : {}),
94
+ }),
95
+ );
96
+ return (rows as TeamMemberRow[]).map((r) => flattenTeamMember(r, locale));
97
+ } catch (err) {
98
+ dkitQueryFailed(`getTeamMembers failed`, err);
99
+ return [];
100
+ }
59
101
  }
60
102
 
61
- export async function getTeamMemberBySlug(slug: string, options: GetTeamMemberBySlugOptions = {}): Promise<TeamMember | null> {
62
- const client = getDirectus(); if (!client) return null;
63
- if (!collections.team_members) { dkitQueryFailed("collections.team_members missing"); return null; }
103
+ export async function getTeamMemberBySlug(
104
+ slug: string,
105
+ options: GetTeamMemberBySlugOptions = {},
106
+ ): Promise<TeamMember | null> {
107
+ const client = getDirectus();
108
+ if (!client) return null;
109
+ if (!collections.team_members) {
110
+ dkitQueryFailed("collections.team_members missing");
111
+ return null;
112
+ }
64
113
  const locale = await resolveLocale(options.locale);
65
114
  const status = statusFilter(options.status);
66
- const and: Record<string, unknown>[] = [{ slug: { _eq: slug } }];
67
- if (status) and.unshift(status);
115
+ const filter = status
116
+ ? { _and: [status, { slug: { _eq: slug } }] }
117
+ : { slug: { _eq: slug } };
68
118
  try {
69
- const rows = await client.request(readItems(collections.team_members, {
70
- filter: { _and: and },
71
- deep: translationsDeepFilter(locale),
72
- fields: [...TEAM_MEMBER_FIELDS],
73
- limit: 1,
74
- }));
75
- const row = (rows as Record<string, unknown>[])[0]; return row ? flattenTeamMember(row, locale) : null;
76
- } catch (err) { dkitQueryFailed(`getTeamMemberBySlug(${slug}) failed`, err); return null; }
119
+ const rows = await client.request(
120
+ readItems(collections.team_members, {
121
+ filter,
122
+ deep: translationsDeepFilter(locale),
123
+ fields: [...TEAM_MEMBER_FIELDS],
124
+ limit: 1,
125
+ }),
126
+ );
127
+ const row = (rows as TeamMemberRow[])[0];
128
+ return row ? flattenTeamMember(row, locale) : null;
129
+ } catch (err) {
130
+ dkitQueryFailed(`getTeamMemberBySlug(${slug}) failed`, err);
131
+ return null;
132
+ }
77
133
  }
78
134
 
79
- export async function getTeamMemberById(id: string, options: GetTeamMemberBySlugOptions = {}): Promise<TeamMember | null> {
80
- const client = getDirectus(); if (!client) return null; if (!collections.team_members) return null;
135
+ export async function getTeamMemberById(
136
+ id: string,
137
+ options: GetTeamMemberBySlugOptions = {},
138
+ ): Promise<TeamMember | null> {
139
+ const client = getDirectus();
140
+ if (!client) return null;
141
+ if (!collections.team_members) return null;
81
142
  const locale = await resolveLocale(options.locale);
82
143
  try {
83
- const row = await client.request(readItem(collections.team_members, id, {
84
- fields: [...TEAM_MEMBER_FIELDS],
85
- }));
86
- return row ? flattenTeamMember(row as Record<string, unknown>, locale) : null;
87
- } catch (err) { dkitQueryFailed(`getTeamMemberById(${id}) failed`, err); return null; }
144
+ const row = await client.request(
145
+ readItem(collections.team_members, id, {
146
+ deep: translationsDeepFilter(locale),
147
+ fields: [...TEAM_MEMBER_FIELDS],
148
+ }),
149
+ );
150
+ return row ? flattenTeamMember(row as TeamMemberRow, locale) : null;
151
+ } catch (err) {
152
+ dkitQueryFailed(`getTeamMemberById(${id}) failed`, err);
153
+ return null;
154
+ }
88
155
  }
@@ -81,12 +81,13 @@ export async function getTeamMemberBySlug(
81
81
  return null;
82
82
  }
83
83
  const status = statusFilter(options.status);
84
- const and: Record<string, unknown>[] = [{ slug: { _eq: slug } }];
85
- if (status) and.unshift(status);
84
+ const filter = status
85
+ ? { _and: [status, { slug: { _eq: slug } }] }
86
+ : { slug: { _eq: slug } };
86
87
  try {
87
88
  const rows = await client.request(
88
89
  readItems(collections.team_members, {
89
- filter: { _and: and },
90
+ filter,
90
91
  fields: [...TEAM_MEMBER_FIELDS],
91
92
  limit: 1,
92
93
  }),
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "files": [
3
3
  {
4
- "id": "t1000000-0000-4000-8000-000000000001",
4
+ "id": "a1000000-0000-4000-8000-000000000001",
5
5
  "filename_download": "morgan-lee-photo.jpg",
6
6
  "title": "Sample photo — Morgan Lee (Unsplash)",
7
7
  "type": "image/jpeg",
8
8
  "path": "assets/morgan-lee-photo.jpg"
9
9
  },
10
10
  {
11
- "id": "t1000000-0000-4000-8000-000000000002",
11
+ "id": "a1000000-0000-4000-8000-000000000002",
12
12
  "filename_download": "taylor-kim-photo.jpg",
13
13
  "title": "Sample photo — Taylor Kim (Unsplash)",
14
14
  "type": "image/jpeg",
@@ -25,7 +25,7 @@
25
25
  "role": "Lead Developer",
26
26
  "bio": "Sample: This team member verifies the name, role, bio, and photo fields render correctly. Replace with your own staff profile before launch.",
27
27
  "email": "morgan@example.com",
28
- "photo": "t1000000-0000-4000-8000-000000000001",
28
+ "photo": "a1000000-0000-4000-8000-000000000001",
29
29
  "sort": 1
30
30
  },
31
31
  {
@@ -35,7 +35,7 @@
35
35
  "slug": "taylor-kim",
36
36
  "role": "Design Director",
37
37
  "bio": "Sample: A second profile confirms grid layout, sort order, and optional-field fallbacks. Safe to delete once verified.",
38
- "photo": "t1000000-0000-4000-8000-000000000002",
38
+ "photo": "a1000000-0000-4000-8000-000000000002",
39
39
  "sort": 2
40
40
  },
41
41
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": [
3
3
  {
4
- "id": "t1000000-0000-4000-8000-000000000001",
4
+ "id": "a1000000-0000-4000-8000-000000000001",
5
5
  "filename_download": "morgan-lee-photo.jpg",
6
6
  "title": "Sample photo — Morgan Lee (Unsplash)",
7
7
  "type": "image/jpeg",
@@ -15,7 +15,7 @@
15
15
  "status": "published",
16
16
  "name": "Alex Sample",
17
17
  "slug": "alex-sample",
18
- "photo": "t1000000-0000-4000-8000-000000000001",
18
+ "photo": "a1000000-0000-4000-8000-000000000001",
19
19
  "sort": 1,
20
20
  "translations": [
21
21
  {
@@ -1,3 +1,5 @@
1
+ type DkitSortField<T extends string> = T | `-${T}`;
2
+
1
3
  export type DirectusFileRef = { id: string };
2
4
 
3
5
  export type TeamMemberTranslation = {
@@ -8,6 +10,17 @@ export type TeamMemberTranslation = {
8
10
  bio?: string | null;
9
11
  };
10
12
 
13
+ export type TeamMemberRow = {
14
+ id: string;
15
+ status: "published" | "draft" | "archived";
16
+ name: string;
17
+ slug: string;
18
+ photo?: string | DirectusFileRef | null;
19
+ email?: string | null;
20
+ sort?: number | null;
21
+ translations?: TeamMemberTranslation[] | null;
22
+ };
23
+
11
24
  export type TeamMember = {
12
25
  id: string;
13
26
  status: "published" | "draft" | "archived";
@@ -21,13 +34,13 @@ export type TeamMember = {
21
34
  };
22
35
 
23
36
  export type GetTeamMembersOptions = {
24
- status?: string | null;
37
+ status?: TeamMember["status"] | null;
25
38
  limit?: number;
26
- sort?: string[];
39
+ sort?: Array<DkitSortField<"sort" | "name" | "id" | "status" | "slug">>;
27
40
  locale?: string;
28
41
  };
29
42
 
30
43
  export type GetTeamMemberBySlugOptions = {
31
- status?: string | null;
44
+ status?: TeamMember["status"] | null;
32
45
  locale?: string;
33
46
  };