@shipsite.dev/core 0.1.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.
package/dist/blog.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ export interface ResolvedArticle {
2
+ slug: string;
3
+ contentKey: string;
4
+ title: string;
5
+ description: string;
6
+ excerpt: string;
7
+ category: string;
8
+ categoryKey: string;
9
+ date: string;
10
+ image: string;
11
+ readingTime: number;
12
+ featured: boolean;
13
+ authorKey: string;
14
+ }
15
+ export interface ResolvedAuthor {
16
+ name: string;
17
+ role: string;
18
+ image: string;
19
+ bio: string;
20
+ }
21
+ export interface ResolvedCategory {
22
+ key: string;
23
+ label: string;
24
+ }
25
+ export declare function getLocalizedField(field: string | Record<string, string> | undefined, locale: string): string;
26
+ export declare function resolveAuthor(key: string, locale: string): ResolvedAuthor | undefined;
27
+ export declare function getBlogArticles(locale: string): ResolvedArticle[];
28
+ export declare function getCategories(locale: string): ResolvedCategory[];
29
+ //# sourceMappingURL=blog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blog.d.ts","sourceRoot":"","sources":["../src/blog.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAClD,MAAM,EAAE,MAAM,GACb,MAAM,CAIR;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,cAAc,GAAG,SAAS,CAc5B;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE,CAwCjE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAOhE"}
package/dist/blog.js ADDED
@@ -0,0 +1,72 @@
1
+ import { allSitePages } from 'content-collections';
2
+ import { getConfig } from './config';
3
+ export function getLocalizedField(field, locale) {
4
+ if (!field)
5
+ return '';
6
+ if (typeof field === 'string')
7
+ return field;
8
+ return field[locale] || field.en || '';
9
+ }
10
+ export function resolveAuthor(key, locale) {
11
+ const config = getConfig();
12
+ const authors = config.blog?.authors;
13
+ if (!authors)
14
+ return undefined;
15
+ const author = authors[key];
16
+ if (!author)
17
+ return undefined;
18
+ return {
19
+ name: author.name,
20
+ role: getLocalizedField(author.role, locale),
21
+ image: author.image || '',
22
+ bio: getLocalizedField(author.bio, locale),
23
+ };
24
+ }
25
+ export function getBlogArticles(locale) {
26
+ const config = getConfig();
27
+ const categories = config.blog?.categories || [];
28
+ const categoryMap = config.blog?.categoryMap || {};
29
+ function normalizeCategoryKey(raw) {
30
+ return categoryMap[raw] || '';
31
+ }
32
+ function getCategoryLabel(key, loc) {
33
+ const entry = categories.find((c) => c.key === key);
34
+ if (!entry)
35
+ return '';
36
+ return entry.label[loc] || entry.label.en || '';
37
+ }
38
+ return allSitePages
39
+ .filter((doc) => doc.kind === 'blog-article' && doc.locale === locale)
40
+ .map((doc) => {
41
+ const contentKey = doc.contentFolder.replace(/^blog\//, '');
42
+ const slug = doc.slug || contentKey;
43
+ const rawCategory = doc.category || '';
44
+ const categoryKey = normalizeCategoryKey(rawCategory);
45
+ return {
46
+ slug,
47
+ contentKey,
48
+ title: doc.title,
49
+ description: doc.description,
50
+ excerpt: doc.excerpt || doc.description,
51
+ category: categoryKey
52
+ ? getCategoryLabel(categoryKey, locale) || rawCategory
53
+ : rawCategory,
54
+ categoryKey,
55
+ date: doc.date || '',
56
+ image: doc.image || '/images/placeholder.webp',
57
+ readingTime: doc.readingTime || 5,
58
+ featured: doc.featured || false,
59
+ authorKey: doc.author || '',
60
+ };
61
+ })
62
+ .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
63
+ }
64
+ export function getCategories(locale) {
65
+ const config = getConfig();
66
+ const categories = config.blog?.categories || [];
67
+ return categories.map((entry) => ({
68
+ key: entry.key,
69
+ label: entry.label[locale] || entry.label.en || entry.key,
70
+ }));
71
+ }
72
+ //# sourceMappingURL=blog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blog.js","sourceRoot":"","sources":["../src/blog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA6BrC,MAAM,UAAU,iBAAiB,CAC/B,KAAkD,EAClD,MAAc;IAEd,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,GAAW,EACX,MAAc;IAEd,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,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C;IACjD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChC,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,GAAG;KAC1D,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,405 @@
1
+ import { z } from 'zod';
2
+ declare const PageConfigSchema: z.ZodObject<{
3
+ slug: z.ZodString;
4
+ type: z.ZodString;
5
+ content: z.ZodString;
6
+ locales: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ type: string;
9
+ slug: string;
10
+ content: string;
11
+ locales?: string[] | undefined;
12
+ }, {
13
+ type: string;
14
+ slug: string;
15
+ content: string;
16
+ locales?: string[] | undefined;
17
+ }>;
18
+ declare const ShipSiteConfigSchema: z.ZodObject<{
19
+ $schema: z.ZodOptional<z.ZodString>;
20
+ name: z.ZodString;
21
+ url: z.ZodString;
22
+ logo: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
23
+ light: z.ZodString;
24
+ dark: z.ZodString;
25
+ }, "strip", z.ZodTypeAny, {
26
+ light: string;
27
+ dark: string;
28
+ }, {
29
+ light: string;
30
+ dark: string;
31
+ }>]>>;
32
+ favicon: z.ZodOptional<z.ZodString>;
33
+ ogImage: z.ZodOptional<z.ZodString>;
34
+ colors: z.ZodOptional<z.ZodObject<{
35
+ primary: z.ZodString;
36
+ accent: z.ZodOptional<z.ZodString>;
37
+ background: z.ZodOptional<z.ZodString>;
38
+ text: z.ZodOptional<z.ZodString>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ primary: string;
41
+ accent?: string | undefined;
42
+ background?: string | undefined;
43
+ text?: string | undefined;
44
+ }, {
45
+ primary: string;
46
+ accent?: string | undefined;
47
+ background?: string | undefined;
48
+ text?: string | undefined;
49
+ }>>;
50
+ fonts: z.ZodOptional<z.ZodObject<{
51
+ heading: z.ZodOptional<z.ZodString>;
52
+ body: z.ZodOptional<z.ZodString>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ heading?: string | undefined;
55
+ body?: string | undefined;
56
+ }, {
57
+ heading?: string | undefined;
58
+ body?: string | undefined;
59
+ }>>;
60
+ i18n: z.ZodOptional<z.ZodObject<{
61
+ defaultLocale: z.ZodDefault<z.ZodString>;
62
+ locales: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
63
+ localePrefix: z.ZodDefault<z.ZodEnum<["as-needed", "always", "never"]>>;
64
+ }, "strip", z.ZodTypeAny, {
65
+ locales: string[];
66
+ defaultLocale: string;
67
+ localePrefix: "never" | "as-needed" | "always";
68
+ }, {
69
+ locales?: string[] | undefined;
70
+ defaultLocale?: string | undefined;
71
+ localePrefix?: "never" | "as-needed" | "always" | undefined;
72
+ }>>;
73
+ navigation: z.ZodOptional<z.ZodObject<{
74
+ items: z.ZodArray<z.ZodObject<{
75
+ label: z.ZodString;
76
+ href: z.ZodString;
77
+ }, "strip", z.ZodTypeAny, {
78
+ label: string;
79
+ href: string;
80
+ }, {
81
+ label: string;
82
+ href: string;
83
+ }>, "many">;
84
+ cta: z.ZodOptional<z.ZodObject<{
85
+ label: z.ZodString;
86
+ href: z.ZodString;
87
+ }, "strip", z.ZodTypeAny, {
88
+ label: string;
89
+ href: string;
90
+ }, {
91
+ label: string;
92
+ href: string;
93
+ }>>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ items: {
96
+ label: string;
97
+ href: string;
98
+ }[];
99
+ cta?: {
100
+ label: string;
101
+ href: string;
102
+ } | undefined;
103
+ }, {
104
+ items: {
105
+ label: string;
106
+ href: string;
107
+ }[];
108
+ cta?: {
109
+ label: string;
110
+ href: string;
111
+ } | undefined;
112
+ }>>;
113
+ footer: z.ZodOptional<z.ZodObject<{
114
+ columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
115
+ title: z.ZodString;
116
+ links: z.ZodArray<z.ZodObject<{
117
+ label: z.ZodString;
118
+ href: z.ZodString;
119
+ }, "strip", z.ZodTypeAny, {
120
+ label: string;
121
+ href: string;
122
+ }, {
123
+ label: string;
124
+ href: string;
125
+ }>, "many">;
126
+ }, "strip", z.ZodTypeAny, {
127
+ title: string;
128
+ links: {
129
+ label: string;
130
+ href: string;
131
+ }[];
132
+ }, {
133
+ title: string;
134
+ links: {
135
+ label: string;
136
+ href: string;
137
+ }[];
138
+ }>, "many">>;
139
+ social: z.ZodOptional<z.ZodArray<z.ZodObject<{
140
+ platform: z.ZodString;
141
+ href: z.ZodString;
142
+ }, "strip", z.ZodTypeAny, {
143
+ href: string;
144
+ platform: string;
145
+ }, {
146
+ href: string;
147
+ platform: string;
148
+ }>, "many">>;
149
+ copyright: z.ZodOptional<z.ZodString>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ columns?: {
152
+ title: string;
153
+ links: {
154
+ label: string;
155
+ href: string;
156
+ }[];
157
+ }[] | undefined;
158
+ social?: {
159
+ href: string;
160
+ platform: string;
161
+ }[] | undefined;
162
+ copyright?: string | undefined;
163
+ }, {
164
+ columns?: {
165
+ title: string;
166
+ links: {
167
+ label: string;
168
+ href: string;
169
+ }[];
170
+ }[] | undefined;
171
+ social?: {
172
+ href: string;
173
+ platform: string;
174
+ }[] | undefined;
175
+ copyright?: string | undefined;
176
+ }>>;
177
+ pages: z.ZodArray<z.ZodObject<{
178
+ slug: z.ZodString;
179
+ type: z.ZodString;
180
+ content: z.ZodString;
181
+ locales: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
182
+ }, "strip", z.ZodTypeAny, {
183
+ type: string;
184
+ slug: string;
185
+ content: string;
186
+ locales?: string[] | undefined;
187
+ }, {
188
+ type: string;
189
+ slug: string;
190
+ content: string;
191
+ locales?: string[] | undefined;
192
+ }>, "many">;
193
+ blog: z.ZodOptional<z.ZodObject<{
194
+ authors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
195
+ name: z.ZodString;
196
+ role: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
197
+ image: z.ZodOptional<z.ZodString>;
198
+ bio: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
199
+ }, "strip", z.ZodTypeAny, {
200
+ name: string;
201
+ role?: string | Record<string, string> | undefined;
202
+ image?: string | undefined;
203
+ bio?: string | Record<string, string> | undefined;
204
+ }, {
205
+ name: string;
206
+ role?: string | Record<string, string> | undefined;
207
+ image?: string | undefined;
208
+ bio?: string | Record<string, string> | undefined;
209
+ }>>>;
210
+ categories: z.ZodOptional<z.ZodArray<z.ZodObject<{
211
+ key: z.ZodString;
212
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ label: Record<string, string>;
215
+ key: string;
216
+ }, {
217
+ label: Record<string, string>;
218
+ key: string;
219
+ }>, "many">>;
220
+ categoryMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ authors?: Record<string, {
223
+ name: string;
224
+ role?: string | Record<string, string> | undefined;
225
+ image?: string | undefined;
226
+ bio?: string | Record<string, string> | undefined;
227
+ }> | undefined;
228
+ categories?: {
229
+ label: Record<string, string>;
230
+ key: string;
231
+ }[] | undefined;
232
+ categoryMap?: Record<string, string> | undefined;
233
+ }, {
234
+ authors?: Record<string, {
235
+ name: string;
236
+ role?: string | Record<string, string> | undefined;
237
+ image?: string | undefined;
238
+ bio?: string | Record<string, string> | undefined;
239
+ }> | undefined;
240
+ categories?: {
241
+ label: Record<string, string>;
242
+ key: string;
243
+ }[] | undefined;
244
+ categoryMap?: Record<string, string> | undefined;
245
+ }>>;
246
+ analytics: z.ZodOptional<z.ZodObject<{
247
+ googleTagManager: z.ZodOptional<z.ZodString>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ googleTagManager?: string | undefined;
250
+ }, {
251
+ googleTagManager?: string | undefined;
252
+ }>>;
253
+ }, "strip", z.ZodTypeAny, {
254
+ name: string;
255
+ url: string;
256
+ pages: {
257
+ type: string;
258
+ slug: string;
259
+ content: string;
260
+ locales?: string[] | undefined;
261
+ }[];
262
+ $schema?: string | undefined;
263
+ logo?: string | {
264
+ light: string;
265
+ dark: string;
266
+ } | undefined;
267
+ favicon?: string | undefined;
268
+ ogImage?: string | undefined;
269
+ colors?: {
270
+ primary: string;
271
+ accent?: string | undefined;
272
+ background?: string | undefined;
273
+ text?: string | undefined;
274
+ } | undefined;
275
+ fonts?: {
276
+ heading?: string | undefined;
277
+ body?: string | undefined;
278
+ } | undefined;
279
+ i18n?: {
280
+ locales: string[];
281
+ defaultLocale: string;
282
+ localePrefix: "never" | "as-needed" | "always";
283
+ } | undefined;
284
+ navigation?: {
285
+ items: {
286
+ label: string;
287
+ href: string;
288
+ }[];
289
+ cta?: {
290
+ label: string;
291
+ href: string;
292
+ } | undefined;
293
+ } | undefined;
294
+ footer?: {
295
+ columns?: {
296
+ title: string;
297
+ links: {
298
+ label: string;
299
+ href: string;
300
+ }[];
301
+ }[] | undefined;
302
+ social?: {
303
+ href: string;
304
+ platform: string;
305
+ }[] | undefined;
306
+ copyright?: string | undefined;
307
+ } | undefined;
308
+ blog?: {
309
+ authors?: Record<string, {
310
+ name: string;
311
+ role?: string | Record<string, string> | undefined;
312
+ image?: string | undefined;
313
+ bio?: string | Record<string, string> | undefined;
314
+ }> | undefined;
315
+ categories?: {
316
+ label: Record<string, string>;
317
+ key: string;
318
+ }[] | undefined;
319
+ categoryMap?: Record<string, string> | undefined;
320
+ } | undefined;
321
+ analytics?: {
322
+ googleTagManager?: string | undefined;
323
+ } | undefined;
324
+ }, {
325
+ name: string;
326
+ url: string;
327
+ pages: {
328
+ type: string;
329
+ slug: string;
330
+ content: string;
331
+ locales?: string[] | undefined;
332
+ }[];
333
+ $schema?: string | undefined;
334
+ logo?: string | {
335
+ light: string;
336
+ dark: string;
337
+ } | undefined;
338
+ favicon?: string | undefined;
339
+ ogImage?: string | undefined;
340
+ colors?: {
341
+ primary: string;
342
+ accent?: string | undefined;
343
+ background?: string | undefined;
344
+ text?: string | undefined;
345
+ } | undefined;
346
+ fonts?: {
347
+ heading?: string | undefined;
348
+ body?: string | undefined;
349
+ } | undefined;
350
+ i18n?: {
351
+ locales?: string[] | undefined;
352
+ defaultLocale?: string | undefined;
353
+ localePrefix?: "never" | "as-needed" | "always" | undefined;
354
+ } | undefined;
355
+ navigation?: {
356
+ items: {
357
+ label: string;
358
+ href: string;
359
+ }[];
360
+ cta?: {
361
+ label: string;
362
+ href: string;
363
+ } | undefined;
364
+ } | undefined;
365
+ footer?: {
366
+ columns?: {
367
+ title: string;
368
+ links: {
369
+ label: string;
370
+ href: string;
371
+ }[];
372
+ }[] | undefined;
373
+ social?: {
374
+ href: string;
375
+ platform: string;
376
+ }[] | undefined;
377
+ copyright?: string | undefined;
378
+ } | undefined;
379
+ blog?: {
380
+ authors?: Record<string, {
381
+ name: string;
382
+ role?: string | Record<string, string> | undefined;
383
+ image?: string | undefined;
384
+ bio?: string | Record<string, string> | undefined;
385
+ }> | undefined;
386
+ categories?: {
387
+ label: Record<string, string>;
388
+ key: string;
389
+ }[] | undefined;
390
+ categoryMap?: Record<string, string> | undefined;
391
+ } | undefined;
392
+ analytics?: {
393
+ googleTagManager?: string | undefined;
394
+ } | undefined;
395
+ }>;
396
+ export type ShipSiteConfig = z.infer<typeof ShipSiteConfigSchema>;
397
+ export type PageConfig = z.infer<typeof PageConfigSchema>;
398
+ export declare function loadConfig(rootDir?: string): ShipSiteConfig;
399
+ export declare function getConfig(): ShipSiteConfig;
400
+ export declare function getSiteUrl(): string;
401
+ export declare function getLocales(): string[];
402
+ export declare function getDefaultLocale(): string;
403
+ export declare function getLocalePrefix(): string;
404
+ export {};
405
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;EAKpB,CAAC;AAwBH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCxB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAK1D,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,CAS3D;AAED,wBAAgB,SAAS,IAAI,cAAc,CAK1C;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAErC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
package/dist/config.js ADDED
@@ -0,0 +1,122 @@
1
+ import { z } from 'zod';
2
+ import { readFileSync } from 'fs';
3
+ import { join } from 'path';
4
+ // ─── Schema ────────────────────────────────────────────────────
5
+ const NavigationItemSchema = z.object({
6
+ label: z.string(),
7
+ href: z.string(),
8
+ });
9
+ const NavigationSchema = z.object({
10
+ items: z.array(NavigationItemSchema),
11
+ cta: NavigationItemSchema.optional(),
12
+ });
13
+ const FooterColumnSchema = z.object({
14
+ title: z.string(),
15
+ links: z.array(z.object({ label: z.string(), href: z.string() })),
16
+ });
17
+ const SocialLinkSchema = z.object({
18
+ platform: z.string(),
19
+ href: z.string(),
20
+ });
21
+ const FooterSchema = z.object({
22
+ columns: z.array(FooterColumnSchema).optional(),
23
+ social: z.array(SocialLinkSchema).optional(),
24
+ copyright: z.string().optional(),
25
+ });
26
+ const PageConfigSchema = z.object({
27
+ slug: z.string(),
28
+ type: z.string(),
29
+ content: z.string(),
30
+ locales: z.array(z.string()).optional(),
31
+ });
32
+ const AuthorSchema = z.object({
33
+ name: z.string(),
34
+ role: z.union([z.string(), z.record(z.string())]).optional(),
35
+ image: z.string().optional(),
36
+ bio: z.union([z.string(), z.record(z.string())]).optional(),
37
+ });
38
+ const BlogConfigSchema = z
39
+ .object({
40
+ authors: z.record(AuthorSchema).optional(),
41
+ categories: z
42
+ .array(z.object({
43
+ key: z.string(),
44
+ label: z.record(z.string()),
45
+ }))
46
+ .optional(),
47
+ categoryMap: z.record(z.string()).optional(),
48
+ })
49
+ .optional();
50
+ const ShipSiteConfigSchema = z.object({
51
+ $schema: z.string().optional(),
52
+ name: z.string(),
53
+ url: z.string().url(),
54
+ logo: z
55
+ .union([z.string(), z.object({ light: z.string(), dark: z.string() })])
56
+ .optional(),
57
+ favicon: z.string().optional(),
58
+ ogImage: z.string().optional(),
59
+ colors: z
60
+ .object({
61
+ primary: z.string(),
62
+ accent: z.string().optional(),
63
+ background: z.string().optional(),
64
+ text: z.string().optional(),
65
+ })
66
+ .optional(),
67
+ fonts: z
68
+ .object({
69
+ heading: z.string().optional(),
70
+ body: z.string().optional(),
71
+ })
72
+ .optional(),
73
+ i18n: z
74
+ .object({
75
+ defaultLocale: z.string().default('en'),
76
+ locales: z.array(z.string()).default(['en']),
77
+ localePrefix: z
78
+ .enum(['as-needed', 'always', 'never'])
79
+ .default('as-needed'),
80
+ })
81
+ .optional(),
82
+ navigation: NavigationSchema.optional(),
83
+ footer: FooterSchema.optional(),
84
+ pages: z.array(PageConfigSchema),
85
+ blog: BlogConfigSchema,
86
+ analytics: z
87
+ .object({
88
+ googleTagManager: z.string().optional(),
89
+ })
90
+ .optional(),
91
+ });
92
+ // ─── Singleton ─────────────────────────────────────────────────
93
+ let _config = null;
94
+ export function loadConfig(rootDir) {
95
+ if (_config)
96
+ return _config;
97
+ const dir = rootDir || process.env.SHIPSITE_ROOT || process.cwd();
98
+ const configPath = join(dir, 'shipsite.json');
99
+ const raw = readFileSync(configPath, 'utf-8');
100
+ const parsed = JSON.parse(raw);
101
+ _config = ShipSiteConfigSchema.parse(parsed);
102
+ return _config;
103
+ }
104
+ export function getConfig() {
105
+ if (!_config) {
106
+ return loadConfig();
107
+ }
108
+ return _config;
109
+ }
110
+ export function getSiteUrl() {
111
+ return getConfig().url;
112
+ }
113
+ export function getLocales() {
114
+ return getConfig().i18n?.locales ?? ['en'];
115
+ }
116
+ export function getDefaultLocale() {
117
+ return getConfig().i18n?.defaultLocale ?? 'en';
118
+ }
119
+ export function getLocalePrefix() {
120
+ return getConfig().i18n?.localePrefix ?? 'as-needed';
121
+ }
122
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,gBAAgB,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