sproutsite 0.5.24 → 0.5.26
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/README.md +13 -6
- package/THIRD_PARTY_NOTICES.md +3 -3
- package/VERSION +1 -1
- package/package.json +1 -1
- package/src/lib/sproutsite/branding.ts +7 -45
- package/src/lib/sproutsite/colors.ts +24 -0
- package/src/lib/sproutsite/hero-background.ts +61 -0
- package/src/lib/sproutsite/public-assets.ts +33 -0
- package/src/lib/sproutsite/remark-links.ts +4 -3
- package/src/lib/sproutsite/site-colors.ts +47 -0
- package/src/lib/sproutsite/site-config.ts +211 -38
- package/src/lib/sproutsite/sitemap.ts +2 -2
- package/src/lib/sproutsite/types.ts +7 -9
- package/src/lib/sproutsite/urls.ts +3 -3
- package/src/lib/sproutsite/validation.ts +4 -1
- package/src/package/config.ts +24 -9
- package/src/package/content.ts +25 -1
- package/src/package/manifest.ts +1 -1
- package/src/package/page.astro +6 -3
- package/src/package/starter-assets/README.md +6 -3
- package/src/themes/default/colors.ts +190 -0
- package/src/themes/default/components/atoms/HeroBackground/HeroBackground.astro +52 -0
- package/src/themes/default/components/atoms/HeroBackground/HeroBackground.css +23 -0
- package/src/themes/default/components/layout/Columns/Columns.css +1 -1
- package/src/themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.astro +8 -5
- package/src/themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.css +1 -1
- package/src/themes/default/components/organisms/BlogIndex/BlogIndex.astro +16 -13
- package/src/themes/default/components/organisms/BlogPost/BlogPost.astro +1 -1
- package/src/themes/default/components/organisms/Footer/Footer.astro +1 -1
- package/src/themes/default/components/organisms/Footer/Footer.css +1 -1
- package/src/themes/default/components/organisms/Header/Header.astro +2 -2
- package/src/themes/default/components/organisms/Header/Header.css +10 -7
- package/src/themes/default/components/organisms/Hero/Hero.astro +12 -13
- package/src/themes/default/components/organisms/Hero/Hero.css +56 -30
- package/src/themes/default/components/organisms/PageTitle/PageTitle.astro +19 -0
- package/src/themes/default/layouts/ErrorPage/ErrorPage.astro +7 -6
- package/src/themes/default/layouts/PageLayout/PageLayout.astro +8 -3
- package/src/themes/default/styles/foundation/tokens.css +1 -0
- package/src/themes/default/styles/theme.css +1 -0
- package/src/themes/default/styles/themes/section-tones.css +7 -3
- package/src/themes/default/assets/hero-waves.svg +0 -41
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
5
|
import type { SiteConfig } from './types.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
validateBrandingFiles,
|
|
10
|
-
} from './branding.js';
|
|
6
|
+
import { publicHeroImage, validateHeroBackground } from './hero-background.js';
|
|
7
|
+
import { brandingSchema, validateBrandingFiles } from './branding.js';
|
|
8
|
+
import { siteColorsSchema } from './site-colors.js';
|
|
11
9
|
|
|
12
10
|
const linkSchema = z.object({
|
|
13
11
|
label: z.string().trim().min(1),
|
|
@@ -63,6 +61,7 @@ const fontSelectionSchema = z
|
|
|
63
61
|
|
|
64
62
|
const siteSchema = z.object({
|
|
65
63
|
branding: brandingSchema.optional(),
|
|
64
|
+
colors: siteColorsSchema.optional(),
|
|
66
65
|
typography: z
|
|
67
66
|
.object({
|
|
68
67
|
headings: fontSelectionSchema,
|
|
@@ -75,8 +74,13 @@ const siteSchema = z.object({
|
|
|
75
74
|
}),
|
|
76
75
|
links: z
|
|
77
76
|
.object({
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
external: z
|
|
78
|
+
.object({
|
|
79
|
+
newTab: z.boolean().optional(),
|
|
80
|
+
icon: z.boolean().optional(),
|
|
81
|
+
})
|
|
82
|
+
.strict()
|
|
83
|
+
.optional(),
|
|
80
84
|
})
|
|
81
85
|
.strict()
|
|
82
86
|
.optional(),
|
|
@@ -85,21 +89,52 @@ const siteSchema = z.object({
|
|
|
85
89
|
base: z
|
|
86
90
|
.string()
|
|
87
91
|
.regex(/^\/(?:[^/].*)?\/$|^\/$/, 'must be / or begin and end with /'),
|
|
88
|
-
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
i18n: z
|
|
93
|
+
.object({
|
|
94
|
+
locale: z
|
|
95
|
+
.string()
|
|
96
|
+
.regex(
|
|
97
|
+
/^[a-z]{2}(?:-[A-Z]{2})?$/,
|
|
98
|
+
'must be a BCP 47 language tag',
|
|
99
|
+
),
|
|
100
|
+
defaultLocale: z.string().regex(/^[a-z]{2}(?:-[A-Z]{2})?$/),
|
|
101
|
+
locales: z
|
|
102
|
+
.array(z.string().regex(/^[a-z]{2}(?:-[A-Z]{2})?$/))
|
|
103
|
+
.min(1)
|
|
104
|
+
.refine(
|
|
105
|
+
(locales) => new Set(locales).size === locales.length,
|
|
106
|
+
'must contain unique locales',
|
|
107
|
+
),
|
|
108
|
+
})
|
|
109
|
+
.strict()
|
|
110
|
+
.superRefine((value, context) => {
|
|
111
|
+
for (const field of ['locale', 'defaultLocale'] as const)
|
|
112
|
+
if (!value.locales.includes(value[field]))
|
|
113
|
+
context.addIssue({
|
|
114
|
+
code: 'custom',
|
|
115
|
+
path: [field],
|
|
116
|
+
message: 'must be included in i18n.locales',
|
|
117
|
+
});
|
|
118
|
+
}),
|
|
119
|
+
hero: z
|
|
120
|
+
.object({
|
|
121
|
+
classes: z.array(heroClass).max(8).default([]),
|
|
122
|
+
'background-image': publicHeroImage.optional(),
|
|
123
|
+
})
|
|
124
|
+
.strict()
|
|
125
|
+
.default({ classes: [] }),
|
|
96
126
|
blog: z
|
|
97
127
|
.object({
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
hero: z
|
|
129
|
+
.object({
|
|
130
|
+
title: z.string().trim().min(1),
|
|
131
|
+
description: z.string().trim().min(1),
|
|
132
|
+
eyebrow: z.string().trim().min(1),
|
|
133
|
+
})
|
|
134
|
+
.strict(),
|
|
135
|
+
articles: z.object({ heading: z.string().trim().min(1) }).strict(),
|
|
102
136
|
})
|
|
137
|
+
.strict()
|
|
103
138
|
.optional(),
|
|
104
139
|
header: z.object({
|
|
105
140
|
links: z
|
|
@@ -172,32 +207,170 @@ const siteSchema = z.object({
|
|
|
172
207
|
}),
|
|
173
208
|
});
|
|
174
209
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
210
|
+
function record(value: unknown): value is Record<string, unknown> {
|
|
211
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Config objects inherit fields; arrays, primitives and explicit null replace. */
|
|
215
|
+
function mergeConfig(
|
|
216
|
+
base: Record<string, unknown>,
|
|
217
|
+
override: Record<string, unknown>,
|
|
218
|
+
): Record<string, unknown> {
|
|
219
|
+
const merged = { ...base };
|
|
220
|
+
for (const [key, value] of Object.entries(override)) {
|
|
221
|
+
if (['__proto__', 'prototype', 'constructor'].includes(key))
|
|
222
|
+
throw new Error(`Unsafe site configuration key: ${key}`);
|
|
223
|
+
merged[key] =
|
|
224
|
+
record(merged[key]) && record(value)
|
|
225
|
+
? mergeConfig(merged[key], value)
|
|
226
|
+
: value;
|
|
227
|
+
}
|
|
228
|
+
return merged;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Read old generated projects as well; never combine competing spellings. */
|
|
232
|
+
function readConfig(
|
|
233
|
+
source: string,
|
|
234
|
+
primary: boolean,
|
|
235
|
+
defaultLocale?: string,
|
|
236
|
+
): Record<string, unknown> {
|
|
237
|
+
const raw: unknown = parse(readFileSync(source, 'utf8'));
|
|
238
|
+
if (!record(raw))
|
|
239
|
+
throw new Error(`Invalid ${source}: expected a configuration object`);
|
|
240
|
+
const result = { ...raw };
|
|
241
|
+
if ('hero-classes' in result)
|
|
242
|
+
throw new Error(
|
|
243
|
+
`Invalid ${source}: hero-classes has moved to hero.classes. Use hero: { classes: [...] }.`,
|
|
244
|
+
);
|
|
245
|
+
if ('language' in result || 'locales' in result) {
|
|
246
|
+
if ('i18n' in result)
|
|
247
|
+
throw new Error(
|
|
248
|
+
`Invalid ${source}: use i18n instead of mixing language/locales with i18n`,
|
|
249
|
+
);
|
|
250
|
+
result.i18n = {
|
|
251
|
+
...(primary
|
|
252
|
+
? {
|
|
253
|
+
defaultLocale: result.language,
|
|
254
|
+
locales: result.locales ?? [result.language],
|
|
255
|
+
}
|
|
256
|
+
: {}),
|
|
257
|
+
...(result.language !== undefined
|
|
258
|
+
? { locale: result.language }
|
|
259
|
+
: {}),
|
|
260
|
+
...(!primary && result.locales !== undefined
|
|
261
|
+
? { locales: result.locales }
|
|
262
|
+
: {}),
|
|
263
|
+
...(!primary && defaultLocale !== undefined
|
|
264
|
+
? { defaultLocale }
|
|
265
|
+
: {}),
|
|
266
|
+
};
|
|
267
|
+
delete result.language;
|
|
268
|
+
delete result.locales;
|
|
269
|
+
}
|
|
183
270
|
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
raw !== null &&
|
|
187
|
-
!Array.isArray(raw)
|
|
271
|
+
record(result.links) &&
|
|
272
|
+
('externalNewTab' in result.links || 'externalIcon' in result.links)
|
|
188
273
|
) {
|
|
189
|
-
const
|
|
190
|
-
|
|
274
|
+
const { externalNewTab, externalIcon, ...links } = result.links;
|
|
275
|
+
if ('external' in links)
|
|
276
|
+
throw new Error(
|
|
277
|
+
`Invalid ${source}: do not mix legacy link options with links.external`,
|
|
278
|
+
);
|
|
279
|
+
result.links = {
|
|
280
|
+
...links,
|
|
281
|
+
external: {
|
|
282
|
+
...(externalNewTab !== undefined
|
|
283
|
+
? { newTab: externalNewTab }
|
|
284
|
+
: {}),
|
|
285
|
+
...(externalIcon !== undefined ? { icon: externalIcon } : {}),
|
|
286
|
+
},
|
|
287
|
+
};
|
|
191
288
|
}
|
|
289
|
+
const blogInput = result.blog;
|
|
290
|
+
if (
|
|
291
|
+
record(blogInput) &&
|
|
292
|
+
['title', 'eyebrow', 'description', 'heading'].some(
|
|
293
|
+
(key) => key in blogInput,
|
|
294
|
+
)
|
|
295
|
+
) {
|
|
296
|
+
const { title, eyebrow, description, heading, ...blog } = blogInput;
|
|
297
|
+
if ('hero' in blog || 'articles' in blog)
|
|
298
|
+
throw new Error(
|
|
299
|
+
`Invalid ${source}: do not mix flat blog options with blog.hero/blog.articles`,
|
|
300
|
+
);
|
|
301
|
+
result.blog = {
|
|
302
|
+
...blog,
|
|
303
|
+
hero: { title, eyebrow, description },
|
|
304
|
+
articles: { heading },
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function parseConfig(
|
|
311
|
+
raw: Record<string, unknown>,
|
|
312
|
+
filename: string,
|
|
313
|
+
root: string,
|
|
314
|
+
): SiteConfig {
|
|
192
315
|
const parsed = siteSchema.safeParse(raw);
|
|
193
|
-
if (!parsed.success)
|
|
316
|
+
if (!parsed.success)
|
|
194
317
|
throw new Error(
|
|
195
318
|
`Invalid src/content/${filename}: ${parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ')}`,
|
|
196
319
|
);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
320
|
+
const config = parsed.data;
|
|
321
|
+
validateHeroBackground(
|
|
322
|
+
config.hero['background-image'],
|
|
323
|
+
`src/content/${filename}`,
|
|
324
|
+
root,
|
|
325
|
+
);
|
|
200
326
|
validateBrandingFiles(config.branding, root, `src/content/${filename}`);
|
|
327
|
+
return config;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export function loadSiteConfig(
|
|
331
|
+
locale?: string,
|
|
332
|
+
root = process.cwd(),
|
|
333
|
+
): SiteConfig {
|
|
334
|
+
const primaryRaw = readConfig(resolve(root, 'src/content/site.yaml'), true);
|
|
335
|
+
const primary = parseConfig(primaryRaw, 'site.yaml', root);
|
|
336
|
+
if (primary.i18n.locale !== primary.i18n.defaultLocale)
|
|
337
|
+
throw new Error(
|
|
338
|
+
'Invalid src/content/site.yaml: i18n.locale must match i18n.defaultLocale in the base configuration',
|
|
339
|
+
);
|
|
340
|
+
const target = locale ?? primary.i18n.defaultLocale;
|
|
341
|
+
if (!primary.i18n.locales.includes(target))
|
|
342
|
+
throw new Error(
|
|
343
|
+
`Invalid site locale ${target}: must be included in i18n.locales`,
|
|
344
|
+
);
|
|
345
|
+
const filename = `site.${target}.yaml`;
|
|
346
|
+
const localized = resolve(root, 'src/content', filename);
|
|
347
|
+
let config = primary;
|
|
348
|
+
if (
|
|
349
|
+
locale !== undefined &&
|
|
350
|
+
(existsSync(localized) || target !== primary.i18n.defaultLocale)
|
|
351
|
+
) {
|
|
352
|
+
const layer = existsSync(localized)
|
|
353
|
+
? readConfig(localized, false, primary.i18n.defaultLocale)
|
|
354
|
+
: {};
|
|
355
|
+
const override = mergeConfig({ i18n: { locale: target } }, layer);
|
|
356
|
+
config = parseConfig(mergeConfig(primaryRaw, override), filename, root);
|
|
357
|
+
if (config.i18n.locale !== target)
|
|
358
|
+
throw new Error(
|
|
359
|
+
`Invalid src/content/${filename}: i18n.locale must be ${target}`,
|
|
360
|
+
);
|
|
361
|
+
for (const field of ['defaultLocale', 'locales'] as const)
|
|
362
|
+
if (
|
|
363
|
+
JSON.stringify(config.i18n[field]) !==
|
|
364
|
+
JSON.stringify(primary.i18n[field])
|
|
365
|
+
)
|
|
366
|
+
throw new Error(
|
|
367
|
+
`Invalid src/content/${filename}: i18n.${field} must match site.yaml`,
|
|
368
|
+
);
|
|
369
|
+
if (config.url !== primary.url || config.base !== primary.base)
|
|
370
|
+
throw new Error(
|
|
371
|
+
`Invalid src/content/${filename}: url and base must match site.yaml`,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
201
374
|
const environmentBase = process.env.SPROUTSITE_BASE;
|
|
202
375
|
if (environmentBase === undefined) return config;
|
|
203
376
|
const base = siteSchema.shape.base.safeParse(environmentBase);
|
|
@@ -43,7 +43,7 @@ export function createSitemapMetadata(root = process.cwd()) {
|
|
|
43
43
|
files: string[];
|
|
44
44
|
directory?: string;
|
|
45
45
|
}[] = [];
|
|
46
|
-
for (const locale of site.locales) {
|
|
46
|
+
for (const locale of site.i18n.locales) {
|
|
47
47
|
const localizedSite = loadSiteConfig(locale, root);
|
|
48
48
|
const siteFiles = [
|
|
49
49
|
join(root, 'src/content/site.yaml'),
|
|
@@ -147,7 +147,7 @@ export function createSitemapMetadata(root = process.cwd()) {
|
|
|
147
147
|
url: candidate.url,
|
|
148
148
|
}));
|
|
149
149
|
const defaultEntry = equivalents.find(
|
|
150
|
-
(candidate) => candidate.locale === site.
|
|
150
|
+
(candidate) => candidate.locale === site.i18n.defaultLocale,
|
|
151
151
|
);
|
|
152
152
|
if (defaultEntry)
|
|
153
153
|
links.push({ lang: 'x-default', url: defaultEntry.url });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Branding } from './branding.js';
|
|
2
|
+
import type { SiteColors } from './site-colors.js';
|
|
2
3
|
|
|
3
4
|
export const tones = ['default', 'muted', 'brand'] as const;
|
|
4
5
|
export type Tone = (typeof tones)[number];
|
|
@@ -31,25 +32,22 @@ export type HeaderItem =
|
|
|
31
32
|
|
|
32
33
|
export interface SiteConfig {
|
|
33
34
|
branding?: Branding;
|
|
35
|
+
colors?: SiteColors;
|
|
34
36
|
name: string;
|
|
35
37
|
url: string;
|
|
36
38
|
base: string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
heroClasses: string[];
|
|
39
|
+
i18n: { locale: string; defaultLocale: string; locales: string[] };
|
|
40
|
+
hero: { classes: string[]; 'background-image'?: string };
|
|
40
41
|
typography: {
|
|
41
42
|
headings: { family: 'serif' | 'sans-serif'; weight: number };
|
|
42
43
|
eyebrow: { family: 'serif' | 'sans-serif'; weight: number };
|
|
43
44
|
};
|
|
44
45
|
links?: {
|
|
45
|
-
|
|
46
|
-
externalIcon?: boolean;
|
|
46
|
+
external?: { newTab?: boolean; icon?: boolean };
|
|
47
47
|
};
|
|
48
48
|
blog?: {
|
|
49
|
-
title: string;
|
|
50
|
-
|
|
51
|
-
eyebrow: string;
|
|
52
|
-
heading: string;
|
|
49
|
+
hero: { title: string; description: string; eyebrow: string };
|
|
50
|
+
articles: { heading: string };
|
|
53
51
|
};
|
|
54
52
|
header: { links: HeaderItem[] };
|
|
55
53
|
footer: {
|
|
@@ -40,9 +40,9 @@ export function withBase(pathname: string, base: string): string {
|
|
|
40
40
|
|
|
41
41
|
export function contentHref(href: string, site: SiteConfig): string {
|
|
42
42
|
if (!href.startsWith('/') || href.startsWith('//')) return href;
|
|
43
|
-
const defaultLocale = site.
|
|
43
|
+
const defaultLocale = site.i18n.defaultLocale;
|
|
44
44
|
const localePrefix =
|
|
45
|
-
site.
|
|
45
|
+
site.i18n.locale === defaultLocale ? '' : `/${site.i18n.locale}`;
|
|
46
46
|
const localizedHref =
|
|
47
47
|
localePrefix === '' ||
|
|
48
48
|
href === localePrefix ||
|
|
@@ -89,7 +89,7 @@ export function externalLinkAttributes(
|
|
|
89
89
|
if (!isExternalWebLink(href, site.url)) return {};
|
|
90
90
|
return {
|
|
91
91
|
'data-external-link': '',
|
|
92
|
-
...(site.links?.
|
|
92
|
+
...(site.links?.external?.newTab !== false
|
|
93
93
|
? { target: '_blank' as const, rel: 'noopener noreferrer' }
|
|
94
94
|
: {}),
|
|
95
95
|
};
|
|
@@ -13,6 +13,7 @@ import { visit } from 'unist-util-visit';
|
|
|
13
13
|
import { loadSiteConfig } from './site-config.js';
|
|
14
14
|
import { heroTypes, sectionSpacings, tones } from './types.js';
|
|
15
15
|
import { isHexColor } from './colors.js';
|
|
16
|
+
import { validateHeroBackground } from './hero-background.js';
|
|
16
17
|
import {
|
|
17
18
|
badgeVariants,
|
|
18
19
|
badgeStyles,
|
|
@@ -78,7 +79,7 @@ const heroSchema = markdownSchema
|
|
|
78
79
|
})
|
|
79
80
|
.optional(),
|
|
80
81
|
classes: z.array(heroClass).max(8).nullable().optional(),
|
|
81
|
-
'background-image': z.string().trim().min(1).optional(),
|
|
82
|
+
'background-image': z.string().trim().min(1).nullable().optional(),
|
|
82
83
|
actions: z.array(heroAction).min(1).max(2).optional(),
|
|
83
84
|
claim: z.string().trim().min(1).optional(),
|
|
84
85
|
tagline: z.string().trim().min(1).optional(),
|
|
@@ -1366,6 +1367,8 @@ export function validateSproutsiteContent(
|
|
|
1366
1367
|
);
|
|
1367
1368
|
if (filename === 'hero.md') {
|
|
1368
1369
|
const heroMetadata = heroSchema.parse(frontmatter);
|
|
1370
|
+
if (heroMetadata['background-image']?.startsWith('/'))
|
|
1371
|
+
validateHeroBackground(heroMetadata['background-image'], path);
|
|
1369
1372
|
for (const action of heroMetadata.actions ?? []) {
|
|
1370
1373
|
if (
|
|
1371
1374
|
/^(?:javascript:|data:)/i.test(action.href) ||
|
package/src/package/config.ts
CHANGED
|
@@ -18,19 +18,27 @@ import { loadSiteConfig } from '../lib/sproutsite/site-config.js';
|
|
|
18
18
|
import { validateSproutsiteContent } from '../lib/sproutsite/validation.js';
|
|
19
19
|
import { createSitemapMetadata } from '../lib/sproutsite/sitemap.js';
|
|
20
20
|
import { validateBrandingImages } from '../lib/sproutsite/branding.js';
|
|
21
|
+
import { validateHeroBackgroundImage } from '../lib/sproutsite/hero-background.js';
|
|
22
|
+
import { colorStyles } from '../themes/default/colors.js';
|
|
21
23
|
|
|
22
24
|
/** Returns the Astro configuration required by the default Sproutsite theme. */
|
|
23
25
|
export function createSproutsiteConfig() {
|
|
24
26
|
validateSproutsiteContent();
|
|
25
27
|
const site = loadSiteConfig();
|
|
28
|
+
for (const locale of site.i18n.locales) {
|
|
29
|
+
colorStyles(
|
|
30
|
+
loadSiteConfig(locale).colors,
|
|
31
|
+
`src/content/site.yaml / site.${locale}.yaml`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
26
34
|
let sitemapMetadata: ReturnType<typeof createSitemapMetadata> | undefined;
|
|
27
35
|
|
|
28
36
|
return {
|
|
29
37
|
site: site.url,
|
|
30
38
|
base: site.base,
|
|
31
39
|
i18n: {
|
|
32
|
-
locales: site.locales,
|
|
33
|
-
defaultLocale: site.
|
|
40
|
+
locales: site.i18n.locales,
|
|
41
|
+
defaultLocale: site.i18n.defaultLocale,
|
|
34
42
|
routing: { prefixDefaultLocale: false },
|
|
35
43
|
},
|
|
36
44
|
integrations: [
|
|
@@ -60,9 +68,15 @@ export function createSproutsiteConfig() {
|
|
|
60
68
|
name: 'sproutsite/default-routes',
|
|
61
69
|
hooks: {
|
|
62
70
|
'astro:config:setup': async ({ injectRoute }) => {
|
|
63
|
-
for (const locale of site.locales) {
|
|
71
|
+
for (const locale of site.i18n.locales) {
|
|
72
|
+
await validateHeroBackgroundImage(
|
|
73
|
+
(locale === site.i18n.defaultLocale
|
|
74
|
+
? site
|
|
75
|
+
: loadSiteConfig(locale)
|
|
76
|
+
).hero['background-image'],
|
|
77
|
+
);
|
|
64
78
|
await validateBrandingImages(
|
|
65
|
-
(locale === site.
|
|
79
|
+
(locale === site.i18n.defaultLocale
|
|
66
80
|
? site
|
|
67
81
|
: loadSiteConfig(locale)
|
|
68
82
|
).branding,
|
|
@@ -78,8 +92,8 @@ export function createSproutsiteConfig() {
|
|
|
78
92
|
entrypoint: new URL('./500.astro', import.meta.url),
|
|
79
93
|
prerender: true,
|
|
80
94
|
});
|
|
81
|
-
for (const locale of site.locales.filter(
|
|
82
|
-
(locale) => locale !== site.
|
|
95
|
+
for (const locale of site.i18n.locales.filter(
|
|
96
|
+
(locale) => locale !== site.i18n.defaultLocale,
|
|
83
97
|
)) {
|
|
84
98
|
for (const status of [404, 500]) {
|
|
85
99
|
injectRoute({
|
|
@@ -115,8 +129,8 @@ export function createSproutsiteConfig() {
|
|
|
115
129
|
);
|
|
116
130
|
// Astro owns error-page rendering. Flatten localized output
|
|
117
131
|
// for web servers that select their error documents by locale.
|
|
118
|
-
for (const locale of site.locales.filter(
|
|
119
|
-
(locale) => locale !== site.
|
|
132
|
+
for (const locale of site.i18n.locales.filter(
|
|
133
|
+
(locale) => locale !== site.i18n.defaultLocale,
|
|
120
134
|
)) {
|
|
121
135
|
for (const status of [404, 500]) {
|
|
122
136
|
const flat = new URL(
|
|
@@ -166,7 +180,8 @@ export function createSproutsiteConfig() {
|
|
|
166
180
|
rehypeExternalLinks,
|
|
167
181
|
{
|
|
168
182
|
url: site.url,
|
|
169
|
-
externalNewTab:
|
|
183
|
+
externalNewTab:
|
|
184
|
+
site.links?.external?.newTab ?? true,
|
|
170
185
|
},
|
|
171
186
|
],
|
|
172
187
|
],
|
package/src/package/content.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineCollection, type ImageFunction } from 'astro:content';
|
|
|
2
2
|
import { glob } from 'astro/loaders';
|
|
3
3
|
import { z } from 'astro/zod';
|
|
4
4
|
import { heroTypes, sectionSpacings, tones } from '../lib/sproutsite/types.js';
|
|
5
|
+
import { publicHeroImage } from '../lib/sproutsite/hero-background.js';
|
|
5
6
|
import { optionalBlogLoader } from './optional-blog-loader.js';
|
|
6
7
|
import { createBlogReadinessLoader } from './blog-state.js';
|
|
7
8
|
|
|
@@ -80,7 +81,30 @@ export function createSproutsiteCollections(
|
|
|
80
81
|
titleHighlight: z.string().trim().min(1).optional(),
|
|
81
82
|
eyebrow: z.string().trim().min(1).optional(),
|
|
82
83
|
classes: z.array(heroClass).max(8).nullable().optional(),
|
|
83
|
-
'background-image':
|
|
84
|
+
'background-image': z
|
|
85
|
+
.union([
|
|
86
|
+
z
|
|
87
|
+
.string()
|
|
88
|
+
.refine(
|
|
89
|
+
(src) => publicHeroImage.safeParse(src).success,
|
|
90
|
+
'must be a public image path',
|
|
91
|
+
),
|
|
92
|
+
z.preprocess((value, context) => {
|
|
93
|
+
if (
|
|
94
|
+
typeof value !== 'string' ||
|
|
95
|
+
!(value.startsWith('./') || value.startsWith('../'))
|
|
96
|
+
) {
|
|
97
|
+
context.addIssue({
|
|
98
|
+
code: 'custom',
|
|
99
|
+
message: 'must be a relative local image path',
|
|
100
|
+
});
|
|
101
|
+
return z.NEVER;
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}, image()),
|
|
105
|
+
])
|
|
106
|
+
.nullable()
|
|
107
|
+
.optional(),
|
|
84
108
|
actions: z.array(heroAction).min(1).max(2).optional(),
|
|
85
109
|
claim: z.string().trim().min(1).optional(),
|
|
86
110
|
tagline: z.string().trim().min(1).optional(),
|
package/src/package/manifest.ts
CHANGED
package/src/package/page.astro
CHANGED
|
@@ -16,8 +16,10 @@ type Locale = 'en' | 'de';
|
|
|
16
16
|
|
|
17
17
|
export { localeOf, logicalId };
|
|
18
18
|
|
|
19
|
-
export async function getSproutsiteStaticPaths(
|
|
20
|
-
|
|
19
|
+
export async function getSproutsiteStaticPaths(
|
|
20
|
+
locale: Locale = loadSiteConfig().i18n.defaultLocale as Locale,
|
|
21
|
+
) {
|
|
22
|
+
if (!loadSiteConfig().i18n.locales.includes(locale)) return [];
|
|
21
23
|
const pages = assemblePages(
|
|
22
24
|
(await getCollection('pages')).filter(
|
|
23
25
|
(entry) => localeOf(entry.id) === locale,
|
|
@@ -105,8 +107,9 @@ const postSections = post
|
|
|
105
107
|
<Hero hero={page.hero!} site={site} Content={hero.Content} />
|
|
106
108
|
) : page.entry.data.layout !== 'landing' ? (
|
|
107
109
|
<PageTitle
|
|
110
|
+
site={site}
|
|
108
111
|
title={page.entry.data.title}
|
|
109
|
-
classes={site.
|
|
112
|
+
classes={site.hero.classes}
|
|
110
113
|
/>
|
|
111
114
|
) : null}
|
|
112
115
|
{sections.map(({ section, rendered }) => (
|
|
@@ -35,9 +35,12 @@ Manifest schema version 1 contains:
|
|
|
35
35
|
image files.
|
|
36
36
|
- `heroExample`: an optional existing-API integration. Copy its `source` to
|
|
37
37
|
`contentDestination` and merge `frontmatter` into the homepage hero. Use the
|
|
38
|
-
same local asset for both languages.
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
same local asset for both languages. This recipe uses Astro's
|
|
39
|
+
local image schema for optimization. Alternatively set the global
|
|
40
|
+
`hero.background-image` to `/images/hero.jpg` after copying public files;
|
|
41
|
+
public images are delivered unchanged. Set `classes: null` to remove the
|
|
42
|
+
default theme classes. The local image independently replaces any global
|
|
43
|
+
background image.
|
|
41
44
|
|
|
42
45
|
Do not merge a second duplicate `branding` YAML key. Keep the existing name,
|
|
43
46
|
URL, locale, typography and navigation configuration. Locale files inherit the
|