sproutsite 0.5.28 → 0.5.29
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 +21 -4
- package/VERSION +1 -1
- package/package.json +35 -3
- package/src/package/404.astro +2 -2
- package/src/package/500.astro +2 -2
- package/src/package/Document.astro +119 -0
- package/src/package/ErrorDocument.astro +28 -0
- package/src/package/branding.ts +53 -0
- package/src/package/components.ts +19 -19
- package/src/package/config.ts +31 -10
- package/src/package/default-components.ts +31 -0
- package/src/package/error-copy.ts +53 -0
- package/src/package/manifest.ts +1 -1
- package/src/package/page.astro +31 -12
- package/src/package/styles.ts +14 -2
- package/src/package/theme-env.d.ts +6 -0
- package/src/package/theme-types.ts +119 -0
- package/src/package/themes.ts +305 -0
- package/src/themes/default/branding.ts +1 -53
- package/src/themes/default/components/layout/Columns/Columns.astro +1 -1
- package/src/themes/default/components/molecules/AccordionItem/AccordionItem.astro +2 -2
- package/src/themes/default/components/molecules/Card/Card.astro +1 -1
- package/src/themes/default/components/molecules/Feature/Feature.astro +1 -1
- package/src/themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.astro +1 -1
- package/src/themes/default/components/molecules/LegalIdentity/LegalIdentity.astro +4 -4
- package/src/themes/default/components/molecules/PrivacyInfrastructure/PrivacyInfrastructure.astro +2 -2
- package/src/themes/default/components/organisms/BlogIndex/BlogIndex.astro +38 -49
- package/src/themes/default/components/organisms/BlogPost/BlogPost.astro +16 -24
- package/src/themes/default/components/organisms/Footer/Footer.astro +3 -3
- package/src/themes/default/components/organisms/Header/Header.astro +4 -4
- package/src/themes/default/components/organisms/Hero/Hero.astro +3 -3
- package/src/themes/default/components/organisms/PageTitle/PageTitle.astro +2 -2
- package/src/themes/default/layouts/ErrorPage/ErrorPage.astro +38 -106
- package/src/themes/default/layouts/PageLayout/PageLayout.astro +6 -112
- package/src/themes/default/layouts/ThemeLayout/ThemeLayout.astro +6 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ComponentProps } from 'astro/types';
|
|
2
|
+
import type { SiteConfig } from '../lib/sproutsite/types.js';
|
|
3
|
+
|
|
4
|
+
export interface ThemeLayoutProps {
|
|
5
|
+
site: SiteConfig;
|
|
6
|
+
route: string;
|
|
7
|
+
layout: 'default' | 'landing';
|
|
8
|
+
}
|
|
9
|
+
export interface DocumentProps {
|
|
10
|
+
site: SiteConfig;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
route: string;
|
|
14
|
+
layout?: 'default' | 'landing';
|
|
15
|
+
noindex?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ErrorPageProps {
|
|
18
|
+
status: 404 | 500;
|
|
19
|
+
site: SiteConfig;
|
|
20
|
+
copy: ReturnType<typeof import('./error-copy.js').errorCopy>;
|
|
21
|
+
}
|
|
22
|
+
/** Public props match the documented content API, including rendered Content slots. */
|
|
23
|
+
export interface ThemeComponentProps {
|
|
24
|
+
Layout: ComponentProps<
|
|
25
|
+
typeof import('../themes/default/layouts/ThemeLayout/ThemeLayout.astro').default
|
|
26
|
+
>;
|
|
27
|
+
Alert: ComponentProps<
|
|
28
|
+
typeof import('../themes/default/components/molecules/Alert/Alert.astro').default
|
|
29
|
+
>;
|
|
30
|
+
ContentTable: ComponentProps<
|
|
31
|
+
typeof import('../themes/default/components/molecules/ContentTable/ContentTable.astro').default
|
|
32
|
+
>;
|
|
33
|
+
FoundationSample: ComponentProps<
|
|
34
|
+
typeof import('../themes/default/components/molecules/FoundationSample/FoundationSample.astro').default
|
|
35
|
+
>;
|
|
36
|
+
Tabs: ComponentProps<
|
|
37
|
+
typeof import('../themes/default/components/molecules/Tabs/Tabs.astro').default
|
|
38
|
+
>;
|
|
39
|
+
Tab: ComponentProps<
|
|
40
|
+
typeof import('../themes/default/components/atoms/Tab/Tab.astro').default
|
|
41
|
+
>;
|
|
42
|
+
Card: ComponentProps<
|
|
43
|
+
typeof import('../themes/default/components/molecules/Card/Card.astro').default
|
|
44
|
+
>;
|
|
45
|
+
CardActions: ComponentProps<
|
|
46
|
+
typeof import('../themes/default/components/molecules/CardActions/CardActions.astro').default
|
|
47
|
+
>;
|
|
48
|
+
ContentImage: ComponentProps<
|
|
49
|
+
typeof import('../themes/default/components/atoms/ContentImage/ContentImage.astro').default
|
|
50
|
+
>;
|
|
51
|
+
Eyebrow: ComponentProps<
|
|
52
|
+
typeof import('../themes/default/components/atoms/Eyebrow/Eyebrow.astro').default
|
|
53
|
+
>;
|
|
54
|
+
Badge: ComponentProps<
|
|
55
|
+
typeof import('../themes/default/components/atoms/Badge/Badge.astro').default
|
|
56
|
+
>;
|
|
57
|
+
Button: ComponentProps<
|
|
58
|
+
typeof import('../themes/default/components/atoms/Button/Button.astro').default
|
|
59
|
+
>;
|
|
60
|
+
Icon: ComponentProps<
|
|
61
|
+
typeof import('../themes/default/components/atoms/Icon/Icon.astro').default
|
|
62
|
+
>;
|
|
63
|
+
Feature: ComponentProps<
|
|
64
|
+
typeof import('../themes/default/components/molecules/Feature/Feature.astro').default
|
|
65
|
+
>;
|
|
66
|
+
LegalIdentity: ComponentProps<
|
|
67
|
+
typeof import('../themes/default/components/molecules/LegalIdentity/LegalIdentity.astro').default
|
|
68
|
+
>;
|
|
69
|
+
PrivacyInfrastructure: ComponentProps<
|
|
70
|
+
typeof import('../themes/default/components/molecules/PrivacyInfrastructure/PrivacyInfrastructure.astro').default
|
|
71
|
+
>;
|
|
72
|
+
Accordion: ComponentProps<
|
|
73
|
+
typeof import('../themes/default/components/molecules/Accordion/Accordion.astro').default
|
|
74
|
+
>;
|
|
75
|
+
AccordionItem: ComponentProps<
|
|
76
|
+
typeof import('../themes/default/components/molecules/AccordionItem/AccordionItem.astro').default
|
|
77
|
+
>;
|
|
78
|
+
Column: ComponentProps<
|
|
79
|
+
typeof import('../themes/default/components/layout/Column/Column.astro').default
|
|
80
|
+
>;
|
|
81
|
+
Columns: ComponentProps<
|
|
82
|
+
typeof import('../themes/default/components/layout/Columns/Columns.astro').default
|
|
83
|
+
>;
|
|
84
|
+
Header: ComponentProps<
|
|
85
|
+
typeof import('../themes/default/components/organisms/Header/Header.astro').default
|
|
86
|
+
>;
|
|
87
|
+
Footer: ComponentProps<
|
|
88
|
+
typeof import('../themes/default/components/organisms/Footer/Footer.astro').default
|
|
89
|
+
>;
|
|
90
|
+
Hero: ComponentProps<
|
|
91
|
+
typeof import('../themes/default/components/organisms/Hero/Hero.astro').default
|
|
92
|
+
>;
|
|
93
|
+
PageTitle: ComponentProps<
|
|
94
|
+
typeof import('../themes/default/components/organisms/PageTitle/PageTitle.astro').default
|
|
95
|
+
>;
|
|
96
|
+
Section: ComponentProps<
|
|
97
|
+
typeof import('../themes/default/components/organisms/Section/Section.astro').default
|
|
98
|
+
>;
|
|
99
|
+
BlogIndex: ComponentProps<
|
|
100
|
+
typeof import('../themes/default/components/organisms/BlogIndex/BlogIndex.astro').default
|
|
101
|
+
>;
|
|
102
|
+
BlogPost: ComponentProps<
|
|
103
|
+
typeof import('../themes/default/components/organisms/BlogPost/BlogPost.astro').default
|
|
104
|
+
>;
|
|
105
|
+
ErrorPage: ComponentProps<
|
|
106
|
+
typeof import('../themes/default/layouts/ErrorPage/ErrorPage.astro').default
|
|
107
|
+
>;
|
|
108
|
+
BrandLogo: ComponentProps<
|
|
109
|
+
typeof import('../themes/default/components/atoms/BrandLogo/BrandLogo.astro').default
|
|
110
|
+
>;
|
|
111
|
+
HeroBackground: ComponentProps<
|
|
112
|
+
typeof import('../themes/default/components/atoms/HeroBackground/HeroBackground.astro').default
|
|
113
|
+
>;
|
|
114
|
+
LanguageSwitcher: ComponentProps<
|
|
115
|
+
typeof import('../themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.astro').default
|
|
116
|
+
>;
|
|
117
|
+
}
|
|
118
|
+
export type ThemeProps<K extends keyof ThemeComponentProps> =
|
|
119
|
+
ThemeComponentProps[K];
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/// <reference path="./theme-env.d.ts" />
|
|
2
|
+
import { statSync } from 'node:fs';
|
|
3
|
+
import { extname } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import type { ThemeComponentProps } from './theme-types.js';
|
|
6
|
+
export type {
|
|
7
|
+
ThemeProps,
|
|
8
|
+
ThemeComponentProps,
|
|
9
|
+
ThemeLayoutProps,
|
|
10
|
+
DocumentProps,
|
|
11
|
+
} from './theme-types.js';
|
|
12
|
+
|
|
13
|
+
export type ThemeComponents = Partial<Record<keyof ThemeComponentProps, URL>>;
|
|
14
|
+
|
|
15
|
+
/** A local, statically imported theme. Astro compiles its selected files normally. */
|
|
16
|
+
export interface SproutsiteTheme {
|
|
17
|
+
name: string;
|
|
18
|
+
extends?: SproutsiteTheme;
|
|
19
|
+
styles?: readonly URL[];
|
|
20
|
+
components?: ThemeComponents;
|
|
21
|
+
/** Inherit the default palette mapping, or opt out for independent CSS. */
|
|
22
|
+
colors?: 'default' | 'none';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const defaultTheme = {
|
|
26
|
+
name: 'default',
|
|
27
|
+
colors: 'default',
|
|
28
|
+
styles: [new URL('../themes/default/styles/theme.css', import.meta.url)],
|
|
29
|
+
components: {
|
|
30
|
+
Layout: new URL(
|
|
31
|
+
'../themes/default/layouts/ThemeLayout/ThemeLayout.astro',
|
|
32
|
+
import.meta.url,
|
|
33
|
+
),
|
|
34
|
+
Alert: new URL(
|
|
35
|
+
'../themes/default/components/molecules/Alert/Alert.astro',
|
|
36
|
+
import.meta.url,
|
|
37
|
+
),
|
|
38
|
+
ContentTable: new URL(
|
|
39
|
+
'../themes/default/components/molecules/ContentTable/ContentTable.astro',
|
|
40
|
+
import.meta.url,
|
|
41
|
+
),
|
|
42
|
+
FoundationSample: new URL(
|
|
43
|
+
'../themes/default/components/molecules/FoundationSample/FoundationSample.astro',
|
|
44
|
+
import.meta.url,
|
|
45
|
+
),
|
|
46
|
+
Tabs: new URL(
|
|
47
|
+
'../themes/default/components/molecules/Tabs/Tabs.astro',
|
|
48
|
+
import.meta.url,
|
|
49
|
+
),
|
|
50
|
+
Tab: new URL(
|
|
51
|
+
'../themes/default/components/atoms/Tab/Tab.astro',
|
|
52
|
+
import.meta.url,
|
|
53
|
+
),
|
|
54
|
+
Card: new URL(
|
|
55
|
+
'../themes/default/components/molecules/Card/Card.astro',
|
|
56
|
+
import.meta.url,
|
|
57
|
+
),
|
|
58
|
+
CardActions: new URL(
|
|
59
|
+
'../themes/default/components/molecules/CardActions/CardActions.astro',
|
|
60
|
+
import.meta.url,
|
|
61
|
+
),
|
|
62
|
+
ContentImage: new URL(
|
|
63
|
+
'../themes/default/components/atoms/ContentImage/ContentImage.astro',
|
|
64
|
+
import.meta.url,
|
|
65
|
+
),
|
|
66
|
+
Eyebrow: new URL(
|
|
67
|
+
'../themes/default/components/atoms/Eyebrow/Eyebrow.astro',
|
|
68
|
+
import.meta.url,
|
|
69
|
+
),
|
|
70
|
+
Badge: new URL(
|
|
71
|
+
'../themes/default/components/atoms/Badge/Badge.astro',
|
|
72
|
+
import.meta.url,
|
|
73
|
+
),
|
|
74
|
+
Button: new URL(
|
|
75
|
+
'../themes/default/components/atoms/Button/Button.astro',
|
|
76
|
+
import.meta.url,
|
|
77
|
+
),
|
|
78
|
+
Icon: new URL(
|
|
79
|
+
'../themes/default/components/atoms/Icon/Icon.astro',
|
|
80
|
+
import.meta.url,
|
|
81
|
+
),
|
|
82
|
+
Feature: new URL(
|
|
83
|
+
'../themes/default/components/molecules/Feature/Feature.astro',
|
|
84
|
+
import.meta.url,
|
|
85
|
+
),
|
|
86
|
+
LegalIdentity: new URL(
|
|
87
|
+
'../themes/default/components/molecules/LegalIdentity/LegalIdentity.astro',
|
|
88
|
+
import.meta.url,
|
|
89
|
+
),
|
|
90
|
+
PrivacyInfrastructure: new URL(
|
|
91
|
+
'../themes/default/components/molecules/PrivacyInfrastructure/PrivacyInfrastructure.astro',
|
|
92
|
+
import.meta.url,
|
|
93
|
+
),
|
|
94
|
+
Accordion: new URL(
|
|
95
|
+
'../themes/default/components/molecules/Accordion/Accordion.astro',
|
|
96
|
+
import.meta.url,
|
|
97
|
+
),
|
|
98
|
+
AccordionItem: new URL(
|
|
99
|
+
'../themes/default/components/molecules/AccordionItem/AccordionItem.astro',
|
|
100
|
+
import.meta.url,
|
|
101
|
+
),
|
|
102
|
+
Column: new URL(
|
|
103
|
+
'../themes/default/components/layout/Column/Column.astro',
|
|
104
|
+
import.meta.url,
|
|
105
|
+
),
|
|
106
|
+
Columns: new URL(
|
|
107
|
+
'../themes/default/components/layout/Columns/Columns.astro',
|
|
108
|
+
import.meta.url,
|
|
109
|
+
),
|
|
110
|
+
Header: new URL(
|
|
111
|
+
'../themes/default/components/organisms/Header/Header.astro',
|
|
112
|
+
import.meta.url,
|
|
113
|
+
),
|
|
114
|
+
Footer: new URL(
|
|
115
|
+
'../themes/default/components/organisms/Footer/Footer.astro',
|
|
116
|
+
import.meta.url,
|
|
117
|
+
),
|
|
118
|
+
Hero: new URL(
|
|
119
|
+
'../themes/default/components/organisms/Hero/Hero.astro',
|
|
120
|
+
import.meta.url,
|
|
121
|
+
),
|
|
122
|
+
PageTitle: new URL(
|
|
123
|
+
'../themes/default/components/organisms/PageTitle/PageTitle.astro',
|
|
124
|
+
import.meta.url,
|
|
125
|
+
),
|
|
126
|
+
Section: new URL(
|
|
127
|
+
'../themes/default/components/organisms/Section/Section.astro',
|
|
128
|
+
import.meta.url,
|
|
129
|
+
),
|
|
130
|
+
BlogIndex: new URL(
|
|
131
|
+
'../themes/default/components/organisms/BlogIndex/BlogIndex.astro',
|
|
132
|
+
import.meta.url,
|
|
133
|
+
),
|
|
134
|
+
BlogPost: new URL(
|
|
135
|
+
'../themes/default/components/organisms/BlogPost/BlogPost.astro',
|
|
136
|
+
import.meta.url,
|
|
137
|
+
),
|
|
138
|
+
ErrorPage: new URL(
|
|
139
|
+
'../themes/default/layouts/ErrorPage/ErrorPage.astro',
|
|
140
|
+
import.meta.url,
|
|
141
|
+
),
|
|
142
|
+
BrandLogo: new URL(
|
|
143
|
+
'../themes/default/components/atoms/BrandLogo/BrandLogo.astro',
|
|
144
|
+
import.meta.url,
|
|
145
|
+
),
|
|
146
|
+
HeroBackground: new URL(
|
|
147
|
+
'../themes/default/components/atoms/HeroBackground/HeroBackground.astro',
|
|
148
|
+
import.meta.url,
|
|
149
|
+
),
|
|
150
|
+
LanguageSwitcher: new URL(
|
|
151
|
+
'../themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.astro',
|
|
152
|
+
import.meta.url,
|
|
153
|
+
),
|
|
154
|
+
},
|
|
155
|
+
} satisfies SproutsiteTheme;
|
|
156
|
+
|
|
157
|
+
export interface ResolvedTheme {
|
|
158
|
+
name: string;
|
|
159
|
+
colors: 'default' | 'none';
|
|
160
|
+
styles: string[];
|
|
161
|
+
components: Record<keyof ThemeComponentProps, string>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function file(path: unknown, extension: string, context: string): string {
|
|
165
|
+
if (
|
|
166
|
+
!(path instanceof URL) ||
|
|
167
|
+
path.protocol !== 'file:' ||
|
|
168
|
+
path.search ||
|
|
169
|
+
path.hash
|
|
170
|
+
)
|
|
171
|
+
throw new Error(
|
|
172
|
+
context + ': expected a local file URL without query or fragment.',
|
|
173
|
+
);
|
|
174
|
+
const absolute = fileURLToPath(path);
|
|
175
|
+
if (extname(absolute) !== extension)
|
|
176
|
+
throw new Error(context + ': expected a ' + extension + ' file.');
|
|
177
|
+
try {
|
|
178
|
+
if (!statSync(absolute).isFile()) throw new Error('not a file');
|
|
179
|
+
} catch {
|
|
180
|
+
throw new Error(
|
|
181
|
+
context +
|
|
182
|
+
': file does not exist or is not a regular file: ' +
|
|
183
|
+
absolute,
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return absolute.replaceAll('\\', '/');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Resolve one inheritance chain; no default fallbacks for independent themes. */
|
|
190
|
+
export function resolveTheme(
|
|
191
|
+
theme: SproutsiteTheme = defaultTheme,
|
|
192
|
+
): ResolvedTheme {
|
|
193
|
+
const chain: SproutsiteTheme[] = [];
|
|
194
|
+
const visited = new Set<SproutsiteTheme>();
|
|
195
|
+
let current: SproutsiteTheme | undefined = theme;
|
|
196
|
+
while (current !== undefined) {
|
|
197
|
+
if (!current || typeof current !== 'object' || Array.isArray(current))
|
|
198
|
+
throw new Error('Sproutsite theme must be an object.');
|
|
199
|
+
if (visited.has(current))
|
|
200
|
+
throw new Error('Circular Sproutsite theme inheritance.');
|
|
201
|
+
if (chain.length >= 32)
|
|
202
|
+
throw new Error('Sproutsite theme inheritance exceeds 32 levels.');
|
|
203
|
+
for (const key of Object.keys(current))
|
|
204
|
+
if (
|
|
205
|
+
!['name', 'extends', 'styles', 'components', 'colors'].includes(
|
|
206
|
+
key,
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
throw new Error('Unknown theme option: ' + key);
|
|
210
|
+
if (
|
|
211
|
+
typeof current.name !== 'string' ||
|
|
212
|
+
!/^[a-z][a-z0-9-]*$/.test(current.name)
|
|
213
|
+
)
|
|
214
|
+
throw new Error(
|
|
215
|
+
'Theme name must use lowercase letters, digits and hyphens.',
|
|
216
|
+
);
|
|
217
|
+
visited.add(current);
|
|
218
|
+
chain.unshift(current);
|
|
219
|
+
current = current.extends;
|
|
220
|
+
}
|
|
221
|
+
const components: Partial<Record<keyof ThemeComponentProps, string>> = {};
|
|
222
|
+
const styles: string[] = [];
|
|
223
|
+
let colors: ResolvedTheme['colors'] = 'none';
|
|
224
|
+
for (const layer of chain) {
|
|
225
|
+
if (layer.colors !== undefined) {
|
|
226
|
+
if (layer.colors !== 'default' && layer.colors !== 'none')
|
|
227
|
+
throw new Error(
|
|
228
|
+
'Theme ' + layer.name + '.colors must be default or none.',
|
|
229
|
+
);
|
|
230
|
+
colors = layer.colors;
|
|
231
|
+
}
|
|
232
|
+
if (layer.styles !== undefined) {
|
|
233
|
+
if (!Array.isArray(layer.styles))
|
|
234
|
+
throw new Error('Theme styles must be an array.');
|
|
235
|
+
for (const path of layer.styles)
|
|
236
|
+
styles.push(
|
|
237
|
+
file(path, '.css', 'Theme ' + layer.name + '.styles'),
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
if (layer.components !== undefined) {
|
|
241
|
+
if (
|
|
242
|
+
!layer.components ||
|
|
243
|
+
typeof layer.components !== 'object' ||
|
|
244
|
+
Array.isArray(layer.components)
|
|
245
|
+
)
|
|
246
|
+
throw new Error('Theme components must be an object.');
|
|
247
|
+
for (const [name, path] of Object.entries(layer.components)) {
|
|
248
|
+
if (!Object.hasOwn(defaultTheme.components, name))
|
|
249
|
+
throw new Error('Unknown theme component: ' + name);
|
|
250
|
+
const key = name as keyof ThemeComponentProps;
|
|
251
|
+
components[key] = file(
|
|
252
|
+
path,
|
|
253
|
+
'.astro',
|
|
254
|
+
'Theme ' + layer.name + '.components.' + name,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const name of Object.keys(
|
|
260
|
+
defaultTheme.components,
|
|
261
|
+
) as (keyof ThemeComponentProps)[])
|
|
262
|
+
if (!components[name])
|
|
263
|
+
throw new Error(
|
|
264
|
+
'Theme ' +
|
|
265
|
+
theme.name +
|
|
266
|
+
' is missing component ' +
|
|
267
|
+
name +
|
|
268
|
+
'. Provide it or extend a complete theme.',
|
|
269
|
+
);
|
|
270
|
+
return {
|
|
271
|
+
name: theme.name,
|
|
272
|
+
colors,
|
|
273
|
+
styles,
|
|
274
|
+
components: components as ResolvedTheme['components'],
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function themeAliases(theme: ResolvedTheme) {
|
|
279
|
+
return Object.entries(theme.components).map(([name, path]) => ({
|
|
280
|
+
find: '#sproutsite/' + name.toLowerCase(),
|
|
281
|
+
replacement: path,
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Select the palette mapper once; evaluate current site data on every render. */
|
|
286
|
+
export function themeDataPlugin(colors: ResolvedTheme['colors']) {
|
|
287
|
+
const id = 'virtual:sproutsite/theme';
|
|
288
|
+
const path = fileURLToPath(
|
|
289
|
+
new URL('../themes/default/colors.ts', import.meta.url),
|
|
290
|
+
).replaceAll('\\', '/');
|
|
291
|
+
return {
|
|
292
|
+
name: 'sproutsite/theme-data',
|
|
293
|
+
resolveId(source: string) {
|
|
294
|
+
if (source === id) return '\0' + id;
|
|
295
|
+
},
|
|
296
|
+
load(source: string) {
|
|
297
|
+
if (source === '\0' + id)
|
|
298
|
+
return colors === 'default'
|
|
299
|
+
? 'export { colorStyles as paletteStyles } from ' +
|
|
300
|
+
JSON.stringify(path) +
|
|
301
|
+
';'
|
|
302
|
+
: 'export function paletteStyles() { return {}; }';
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
@@ -1,53 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import appleTouch from '../../package/starter-assets/public/branding/apple-touch-icon.png';
|
|
3
|
-
import app192 from '../../package/starter-assets/public/branding/icon-192.png';
|
|
4
|
-
import app512 from '../../package/starter-assets/public/branding/icon-512.png';
|
|
5
|
-
import type { SiteConfig } from '../../lib/sproutsite/types.js';
|
|
6
|
-
import { withBase } from '../../lib/sproutsite/urls.js';
|
|
7
|
-
import { brandingImageMetadata } from '../../lib/sproutsite/branding.js';
|
|
8
|
-
|
|
9
|
-
/** Theme defaults are neutral; all configured files belong to the website. */
|
|
10
|
-
export async function resolveBranding(site: SiteConfig) {
|
|
11
|
-
const icons = site.branding?.icons;
|
|
12
|
-
const publicUrl = (src: string) => withBase(src, site.base);
|
|
13
|
-
const faviconSrc = icons?.favicon ? publicUrl(icons.favicon) : favicon;
|
|
14
|
-
const faviconType = faviconSrc.toLowerCase().endsWith('.svg')
|
|
15
|
-
? 'image/svg+xml'
|
|
16
|
-
: faviconSrc.toLowerCase().endsWith('.png')
|
|
17
|
-
? 'image/png'
|
|
18
|
-
: 'image/x-icon';
|
|
19
|
-
const sharing = site.branding?.sharingImage;
|
|
20
|
-
const metadata = sharing
|
|
21
|
-
? await brandingImageMetadata(sharing.src)
|
|
22
|
-
: undefined;
|
|
23
|
-
return {
|
|
24
|
-
favicon: { src: faviconSrc, type: faviconType },
|
|
25
|
-
shortcut: icons?.shortcut ? publicUrl(icons.shortcut) : undefined,
|
|
26
|
-
appleTouch: icons?.appleTouch
|
|
27
|
-
? publicUrl(icons.appleTouch)
|
|
28
|
-
: appleTouch.src,
|
|
29
|
-
appIcons: [
|
|
30
|
-
{
|
|
31
|
-
src: icons?.app192 ? publicUrl(icons.app192) : app192.src,
|
|
32
|
-
sizes: '192x192',
|
|
33
|
-
type: 'image/png',
|
|
34
|
-
purpose: 'any',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
src: icons?.app512 ? publicUrl(icons.app512) : app512.src,
|
|
38
|
-
sizes: '512x512',
|
|
39
|
-
type: 'image/png',
|
|
40
|
-
purpose: 'any',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
sharingImage:
|
|
44
|
-
sharing && metadata
|
|
45
|
-
? {
|
|
46
|
-
src: new URL(publicUrl(sharing.src), site.url).href,
|
|
47
|
-
alt: sharing.alt,
|
|
48
|
-
width: metadata.width,
|
|
49
|
-
height: metadata.height,
|
|
50
|
-
}
|
|
51
|
-
: undefined,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
1
|
+
export { resolveBranding } from '../../package/branding.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { isHexColor } from '../../../../../lib/sproutsite/colors.js';
|
|
3
3
|
import type { ComponentProps } from 'astro/types';
|
|
4
|
-
import Icon from '
|
|
4
|
+
import Icon from '#sproutsite/icon';
|
|
5
5
|
|
|
6
6
|
const gapSizes = ['xs', 'sm', 'md', 'lg', 'xl'] as const;
|
|
7
7
|
type GapSize = (typeof gapSizes)[number];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { ComponentProps } from 'astro/types';
|
|
3
|
-
import Icon from '
|
|
4
|
-
import type Feature from '
|
|
3
|
+
import Icon from '#sproutsite/icon';
|
|
4
|
+
import type Feature from '#sproutsite/feature';
|
|
5
5
|
import { isHexColor } from '../../../../../lib/sproutsite/colors.js';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { ComponentProps } from 'astro/types';
|
|
3
|
-
import Icon from '
|
|
3
|
+
import Icon from '#sproutsite/icon';
|
|
4
4
|
import { isHexColor } from '../../../../../lib/sproutsite/colors.js';
|
|
5
5
|
|
|
6
6
|
/** A compact benefit with a decorative icon, heading, and Markdown description. */
|
|
@@ -5,7 +5,7 @@ import type { SiteConfig } from '../../../../../lib/sproutsite/types.js';
|
|
|
5
5
|
import { languageLinks } from '../../../../../lib/sproutsite/language-links.js';
|
|
6
6
|
import { withBase } from '../../../../../lib/sproutsite/urls.js';
|
|
7
7
|
import { t } from '../../../i18n/index.js';
|
|
8
|
-
import Icon from '
|
|
8
|
+
import Icon from '#sproutsite/icon';
|
|
9
9
|
import englishFlag from 'flag-icons/flags/4x3/gb.svg?url&no-inline';
|
|
10
10
|
import germanFlag from 'flag-icons/flags/4x3/de.svg?url&no-inline';
|
|
11
11
|
import { getBlogCollection } from '../../../../../package/blog.js';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { loadLegalIdentity } from '../../../../../lib/sproutsite/legal-identity.js';
|
|
3
3
|
import { loadSiteConfig } from '../../../../../lib/sproutsite/site-config.js';
|
|
4
4
|
import { externalLinkAttributes } from '../../../../../lib/sproutsite/urls.js';
|
|
5
|
-
import Column from '
|
|
6
|
-
import Columns from '
|
|
7
|
-
import Feature from '
|
|
8
|
-
import Alert from '
|
|
5
|
+
import Column from '#sproutsite/column';
|
|
6
|
+
import Columns from '#sproutsite/columns';
|
|
7
|
+
import Feature from '#sproutsite/feature';
|
|
8
|
+
import Alert from '#sproutsite/alert';
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
11
|
part?: 'contact' | 'name' | 'email' | 'controller';
|
package/src/themes/default/components/molecules/PrivacyInfrastructure/PrivacyInfrastructure.astro
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { loadPrivacyInfrastructure } from '../../../../../lib/sproutsite/privacy-infrastructure.js';
|
|
3
3
|
import { loadSiteConfig } from '../../../../../lib/sproutsite/site-config.js';
|
|
4
4
|
import { externalLinkAttributes } from '../../../../../lib/sproutsite/urls.js';
|
|
5
|
-
import Feature from '
|
|
6
|
-
import Alert from '
|
|
5
|
+
import Feature from '#sproutsite/feature';
|
|
6
|
+
import Alert from '#sproutsite/alert';
|
|
7
7
|
interface Props {
|
|
8
8
|
part?: 'hosting' | 'email-retention' | 'log-size-limit' | 'log-retention';
|
|
9
9
|
}
|