ferst-core 0.14.0 → 0.16.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/README.md +13 -4
- package/bin/ferst-media.mjs +96 -0
- package/cms/config.template.yml +11 -0
- package/components/Card.astro +53 -51
- package/components/PostCard.astro +138 -136
- package/components/SiteHeader.astro +1356 -1273
- package/components/blocks/Grid.astro +49 -48
- package/components/blocks/Heading.astro +4 -1
- package/components/recipes/Banner.astro +146 -146
- package/components/recipes/Book.astro +39 -4
- package/components/recipes/FeatureCards.astro +112 -118
- package/components/recipes/Gallery.astro +57 -59
- package/components/recipes/Hero.astro +638 -533
- package/components/recipes/LatestPosts.astro +295 -292
- package/components/recipes/Locations.astro +146 -143
- package/components/recipes/Marquee.astro +75 -75
- package/components/recipes/MediaCards.astro +213 -219
- package/components/recipes/Pricing.astro +149 -150
- package/components/recipes/Stats.astro +150 -157
- package/components/recipes/Tiles.astro +342 -296
- package/content/blocks.ts +1072 -1024
- package/content/imageSlots.mjs +542 -0
- package/content/schemas.ts +35 -2
- package/examples/recipes.ts +4 -0
- package/fonts/OFL.txt +1332 -287
- package/fonts/anton-latin-400-normal.woff2 +0 -0
- package/fonts/bangers-latin-400-normal.woff2 +0 -0
- package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
- package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
- package/fonts/fredoka-latin-400-normal.woff2 +0 -0
- package/fonts/fredoka-latin-600-normal.woff2 +0 -0
- package/fonts/fredoka-latin-700-normal.woff2 +0 -0
- package/fonts/knewave-latin-400-normal.woff2 +0 -0
- package/fonts/lora-latin-400-normal.woff2 +0 -0
- package/fonts/lora-latin-600-normal.woff2 +0 -0
- package/fonts/lora-latin-700-normal.woff2 +0 -0
- package/fonts/merriweather-latin-400-normal.woff2 +0 -0
- package/fonts/merriweather-latin-600-normal.woff2 +0 -0
- package/fonts/merriweather-latin-700-normal.woff2 +0 -0
- package/fonts/nunito-latin-400-normal.woff2 +0 -0
- package/fonts/nunito-latin-600-normal.woff2 +0 -0
- package/fonts/nunito-latin-700-normal.woff2 +0 -0
- package/fonts/oswald-latin-400-normal.woff2 +0 -0
- package/fonts/oswald-latin-600-normal.woff2 +0 -0
- package/fonts/oswald-latin-700-normal.woff2 +0 -0
- package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
- package/integration.mjs +253 -249
- package/layouts/Base.astro +13 -3
- package/lib/book.ts +94 -1
- package/lib/fonts.ts +130 -0
- package/lib/gridRows.ts +197 -0
- package/lib/image-fields.ts +140 -0
- package/lib/image-size.mjs +108 -0
- package/lib/image-sizes.ts +16 -0
- package/lib/logo-header.ts +46 -0
- package/lib/media-check.mjs +524 -0
- package/lib/theme-preview.ts +203 -140
- package/lib/themeTokens.ts +235 -220
- package/package.json +3 -2
- package/styles/fonts.css +239 -76
- package/styles/theme.css +228 -160
- package/lib/gridColumns.ts +0 -22
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/integration.mjs
CHANGED
|
@@ -1,249 +1,253 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ferst() — the Astro integration that makes a client site's ROUTING package-owned.
|
|
3
|
-
*
|
|
4
|
-
* A thin client adds `integrations: [ferst()]` to astro.config.mjs and carries
|
|
5
|
-
* ZERO page files: the page catch-all (which also owns the home page), the
|
|
6
|
-
* calendar route and the blog routes are injected from ferst-core. A routing fix
|
|
7
|
-
* then ships as a package bump + rebuild — the same channel component fixes travel
|
|
8
|
-
* through — instead of being hand-copied into every client repo.
|
|
9
|
-
*
|
|
10
|
-
* Irreducible caveat (Astro 5): content collections must be defined in the CONSUMER,
|
|
11
|
-
* so the one-line `src/content/config.ts` re-export stays. "Zero page files" is
|
|
12
|
-
* reachable; "zero files" is not. Explicit client `.astro` routes still win over
|
|
13
|
-
* these injected ones, so a one-off hand-built page is always possible.
|
|
14
|
-
*
|
|
15
|
-
* The blog routes (posts index / individual post / tag pages) inject as a set:
|
|
16
|
-
* the listing components (NewsList, PostsFilter) now live in core, so `/posts`,
|
|
17
|
-
* `/posts/[...slug]` and `/posts/tag/[...tag]` all ship from the package. Turn
|
|
18
|
-
* the whole capability off with `blog: false` (then a client wanting posts hand-
|
|
19
|
-
* builds its own routes over `ferst-core/lib/posts`).
|
|
20
|
-
*
|
|
21
|
-
* @param {object} [options]
|
|
22
|
-
* @param {boolean} [options.calendar=true] Inject the `/calendar` route.
|
|
23
|
-
* @param {boolean} [options.blog=true] Inject the blog routes (`/posts`,
|
|
24
|
-
* `/posts/[...slug]`, `/posts/tag/[...tag]`).
|
|
25
|
-
* @param {boolean} [options.accessibility=true] Inject `/accessibility`, the accessibility statement
|
|
26
|
-
* every footer links to (content/accessibility.ts). Skipped when the site has its own
|
|
27
|
-
* `src/pages/accessibility.astro`.
|
|
28
|
-
* @param {boolean} [options.cookiePolicy=true] Inject `/cookie-policy` (the page the cookie
|
|
29
|
-
* banner links to), generated from the blocks the site uses. Skipped automatically when
|
|
30
|
-
* the site has its own `src/pages/cookie-policy.astro`.
|
|
31
|
-
* @param {boolean} [options.notFound=true] Inject the "page not found" page (`/404` →
|
|
32
|
-
* `404.html`). Cloudflare Pages answers a missing address with it and a real 404 status;
|
|
33
|
-
* without one it serves the home page with a 200 (a "soft 404"). Skipped automatically
|
|
34
|
-
* when the site has its own `src/pages/404.astro` or `public/404.html`.
|
|
35
|
-
* @param {boolean} [options.icons=true] The browser icon (lib/site-icon.mjs): `/favicon.ico` and
|
|
36
|
-
* `/apple-touch-icon.png` in every build, from the icon set in the CMS, else a roughly
|
|
37
|
-
* square logo, else the site's initial in its brand colour. A site's own files in
|
|
38
|
-
* `public/` win.
|
|
39
|
-
* @param {boolean} [options.seo=true] Search signals (lib/seo.mjs): `/robots.txt`, and once
|
|
40
|
-
* `ferst-site.json` has a `siteUrl`, `/sitemap.xml`, a canonical address on every page,
|
|
41
|
-
* structured data and link previews, and (with the blog) `/posts/rss.xml`. Every build's
|
|
42
|
-
* internal links to a page point at its own address (`/about-us/`), not at a redirect.
|
|
43
|
-
* A test copy (any branch but the production one) is marked noindex on every file. A
|
|
44
|
-
* site's own `public/robots.txt` or `public/sitemap.xml` wins.
|
|
45
|
-
* @returns {import('astro').AstroIntegration}
|
|
46
|
-
*/
|
|
47
|
-
import { copyFileSync, createReadStream, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
48
|
-
import { deploymentBranch } from './bin/cms-config.mjs';
|
|
49
|
-
import { linksToPageAddresses, seoContext, withNoindexHeader } from './lib/seo.mjs';
|
|
50
|
-
import { writeSiteIcons } from './lib/site-icon.mjs';
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
res.setHeader('
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// `
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// the
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
'import.meta.env.
|
|
186
|
-
'import.meta.env.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
injectRoute({ pattern: '/
|
|
210
|
-
}
|
|
211
|
-
//
|
|
212
|
-
if (search.siteUrl &&
|
|
213
|
-
injectRoute({ pattern: '/
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* ferst() — the Astro integration that makes a client site's ROUTING package-owned.
|
|
3
|
+
*
|
|
4
|
+
* A thin client adds `integrations: [ferst()]` to astro.config.mjs and carries
|
|
5
|
+
* ZERO page files: the page catch-all (which also owns the home page), the
|
|
6
|
+
* calendar route and the blog routes are injected from ferst-core. A routing fix
|
|
7
|
+
* then ships as a package bump + rebuild — the same channel component fixes travel
|
|
8
|
+
* through — instead of being hand-copied into every client repo.
|
|
9
|
+
*
|
|
10
|
+
* Irreducible caveat (Astro 5): content collections must be defined in the CONSUMER,
|
|
11
|
+
* so the one-line `src/content/config.ts` re-export stays. "Zero page files" is
|
|
12
|
+
* reachable; "zero files" is not. Explicit client `.astro` routes still win over
|
|
13
|
+
* these injected ones, so a one-off hand-built page is always possible.
|
|
14
|
+
*
|
|
15
|
+
* The blog routes (posts index / individual post / tag pages) inject as a set:
|
|
16
|
+
* the listing components (NewsList, PostsFilter) now live in core, so `/posts`,
|
|
17
|
+
* `/posts/[...slug]` and `/posts/tag/[...tag]` all ship from the package. Turn
|
|
18
|
+
* the whole capability off with `blog: false` (then a client wanting posts hand-
|
|
19
|
+
* builds its own routes over `ferst-core/lib/posts`).
|
|
20
|
+
*
|
|
21
|
+
* @param {object} [options]
|
|
22
|
+
* @param {boolean} [options.calendar=true] Inject the `/calendar` route.
|
|
23
|
+
* @param {boolean} [options.blog=true] Inject the blog routes (`/posts`,
|
|
24
|
+
* `/posts/[...slug]`, `/posts/tag/[...tag]`).
|
|
25
|
+
* @param {boolean} [options.accessibility=true] Inject `/accessibility`, the accessibility statement
|
|
26
|
+
* every footer links to (content/accessibility.ts). Skipped when the site has its own
|
|
27
|
+
* `src/pages/accessibility.astro`.
|
|
28
|
+
* @param {boolean} [options.cookiePolicy=true] Inject `/cookie-policy` (the page the cookie
|
|
29
|
+
* banner links to), generated from the blocks the site uses. Skipped automatically when
|
|
30
|
+
* the site has its own `src/pages/cookie-policy.astro`.
|
|
31
|
+
* @param {boolean} [options.notFound=true] Inject the "page not found" page (`/404` →
|
|
32
|
+
* `404.html`). Cloudflare Pages answers a missing address with it and a real 404 status;
|
|
33
|
+
* without one it serves the home page with a 200 (a "soft 404"). Skipped automatically
|
|
34
|
+
* when the site has its own `src/pages/404.astro` or `public/404.html`.
|
|
35
|
+
* @param {boolean} [options.icons=true] The browser icon (lib/site-icon.mjs): `/favicon.ico` and
|
|
36
|
+
* `/apple-touch-icon.png` in every build, from the icon set in the CMS, else a roughly
|
|
37
|
+
* square logo, else the site's initial in its brand colour. A site's own files in
|
|
38
|
+
* `public/` win.
|
|
39
|
+
* @param {boolean} [options.seo=true] Search signals (lib/seo.mjs): `/robots.txt`, and once
|
|
40
|
+
* `ferst-site.json` has a `siteUrl`, `/sitemap.xml`, a canonical address on every page,
|
|
41
|
+
* structured data and link previews, and (with the blog) `/posts/rss.xml`. Every build's
|
|
42
|
+
* internal links to a page point at its own address (`/about-us/`), not at a redirect.
|
|
43
|
+
* A test copy (any branch but the production one) is marked noindex on every file. A
|
|
44
|
+
* site's own `public/robots.txt` or `public/sitemap.xml` wins.
|
|
45
|
+
* @returns {import('astro').AstroIntegration}
|
|
46
|
+
*/
|
|
47
|
+
import { copyFileSync, createReadStream, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
48
|
+
import { deploymentBranch } from './bin/cms-config.mjs';
|
|
49
|
+
import { linksToPageAddresses, seoContext, withNoindexHeader } from './lib/seo.mjs';
|
|
50
|
+
import { writeSiteIcons } from './lib/site-icon.mjs';
|
|
51
|
+
import { publicImageSizes } from './lib/image-size.mjs';
|
|
52
|
+
|
|
53
|
+
/** Every page of a build (its .html files, at any depth), as file URLs. */
|
|
54
|
+
function htmlFiles(dir) {
|
|
55
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) =>
|
|
56
|
+
entry.isDirectory()
|
|
57
|
+
? htmlFiles(new URL(`${encodeURIComponent(entry.name)}/`, dir))
|
|
58
|
+
: entry.name.endsWith('.html')
|
|
59
|
+
? [new URL(encodeURIComponent(entry.name), dir)]
|
|
60
|
+
: [],
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The self-hosted fonts the engine's CSS requests (/fonts/*.woff2), shipped in the package. */
|
|
65
|
+
const FONTS_DIR = new URL('./fonts/', import.meta.url);
|
|
66
|
+
const FONT_URL = /^\/fonts\/([a-z0-9-]+\.woff2)(?:\?.*)?$/;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* ferstFonts() — serves the engine's self-hosted fonts in `astro dev` and copies them into
|
|
70
|
+
* every build's `/fonts/`. Included in ferst(); usable on its own (the showcase). A file
|
|
71
|
+
* the site already has in its own `public/fonts/` is never overwritten.
|
|
72
|
+
* @returns {import('astro').AstroIntegration}
|
|
73
|
+
*/
|
|
74
|
+
export function ferstFonts() {
|
|
75
|
+
return {
|
|
76
|
+
name: 'ferst-fonts',
|
|
77
|
+
hooks: {
|
|
78
|
+
'astro:server:setup': ({ server }) => {
|
|
79
|
+
server.middlewares.use((req, res, next) => {
|
|
80
|
+
const m = req.url && req.url.match(FONT_URL);
|
|
81
|
+
if (!m) return next();
|
|
82
|
+
const file = new URL(m[1], FONTS_DIR);
|
|
83
|
+
if (!existsSync(file)) return next();
|
|
84
|
+
res.setHeader('Content-Type', 'font/woff2');
|
|
85
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
|
|
86
|
+
createReadStream(file).pipe(res);
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
'astro:build:done': async ({ dir }) => {
|
|
90
|
+
const out = new URL('fonts/', dir);
|
|
91
|
+
mkdirSync(out, { recursive: true });
|
|
92
|
+
for (const name of readdirSync(FONTS_DIR)) {
|
|
93
|
+
if (!name.endsWith('.woff2')) continue;
|
|
94
|
+
const dest = new URL(name, out);
|
|
95
|
+
if (!existsSync(dest)) copyFileSync(new URL(name, FONTS_DIR), dest);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The site's `ferst-site.json`, or null (no file, or not JSON). */
|
|
103
|
+
function readSiteMeta(root) {
|
|
104
|
+
if (!root) return null;
|
|
105
|
+
try {
|
|
106
|
+
return JSON.parse(readFileSync(new URL('ferst-site.json', root), 'utf8'));
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Does the site ship this file in its own `public/`? (Its own file wins over ours.) */
|
|
113
|
+
const hasPublicFile = (root, name) => Boolean(root) && existsSync(new URL(`public/${name}`, root));
|
|
114
|
+
|
|
115
|
+
export default function ferst(options = {}) {
|
|
116
|
+
const { calendar = true, blog = true, cookiePolicy = true, accessibility = true, notFound = true, icons = true, seo = true } = options;
|
|
117
|
+
const fonts = ferstFonts().hooks;
|
|
118
|
+
/** This build's search context, decided at setup and used again when the build is done. */
|
|
119
|
+
let search = null;
|
|
120
|
+
/** The site's folder, for the content and public files the build-done steps read. */
|
|
121
|
+
let siteRoot = null;
|
|
122
|
+
return {
|
|
123
|
+
name: 'ferst',
|
|
124
|
+
hooks: {
|
|
125
|
+
'astro:config:setup': ({ injectRoute, updateConfig, config }) => {
|
|
126
|
+
siteRoot = config?.root ?? null;
|
|
127
|
+
// Pages + home: the reserved `index` entry renders at `/`, every other
|
|
128
|
+
// `pages` entry at its own slug (see lib/pages.ts `getSiteRoutes`).
|
|
129
|
+
injectRoute({
|
|
130
|
+
pattern: '/[...slug]',
|
|
131
|
+
entrypoint: 'ferst-core/routes/[...slug].astro',
|
|
132
|
+
});
|
|
133
|
+
if (calendar) {
|
|
134
|
+
injectRoute({
|
|
135
|
+
pattern: '/calendar',
|
|
136
|
+
entrypoint: 'ferst-core/routes/calendar/index.astro',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (blog) {
|
|
140
|
+
// The posts capability: index, individual post, and tag pages. Reads
|
|
141
|
+
// the `posts`/`tags`/`postsSettings` collections (content/collections.ts).
|
|
142
|
+
injectRoute({
|
|
143
|
+
pattern: '/posts',
|
|
144
|
+
entrypoint: 'ferst-core/routes/posts/index.astro',
|
|
145
|
+
});
|
|
146
|
+
injectRoute({
|
|
147
|
+
pattern: '/posts/[...slug]',
|
|
148
|
+
entrypoint: 'ferst-core/routes/posts/[...slug].astro',
|
|
149
|
+
});
|
|
150
|
+
injectRoute({
|
|
151
|
+
pattern: '/posts/tag/[...tag]',
|
|
152
|
+
entrypoint: 'ferst-core/routes/posts/tag/[...tag].astro',
|
|
153
|
+
});
|
|
154
|
+
// Index pages 2+ (page 1 is /posts; tag pages paginate inside their own route).
|
|
155
|
+
injectRoute({
|
|
156
|
+
pattern: '/posts/page/[page]',
|
|
157
|
+
entrypoint: 'ferst-core/routes/posts/page/[page].astro',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// The cookie banner links here on every page, so it must always resolve. A site's
|
|
161
|
+
// own hand-built page wins (Astro would otherwise see two routes for one path).
|
|
162
|
+
const bespoke = config?.root && existsSync(new URL('src/pages/cookie-policy.astro', config.root));
|
|
163
|
+
if (cookiePolicy && !bespoke) {
|
|
164
|
+
injectRoute({
|
|
165
|
+
pattern: '/cookie-policy',
|
|
166
|
+
entrypoint: 'ferst-core/routes/cookie-policy.astro',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// Every footer links to the accessibility statement. The site's own page wins.
|
|
170
|
+
const ownStatement = config?.root && existsSync(new URL('src/pages/accessibility.astro', config.root));
|
|
171
|
+
if (accessibility && !ownStatement) {
|
|
172
|
+
injectRoute({ pattern: '/accessibility', entrypoint: 'ferst-core/routes/accessibility.astro' });
|
|
173
|
+
}
|
|
174
|
+
// A missing address must answer 404, not the home page (Cloudflare Pages serves the
|
|
175
|
+
// home page with a 200 when a build has no 404.html). The site's own page wins.
|
|
176
|
+
const ownNotFound = config?.root && existsSync(new URL('src/pages/404.astro', config.root));
|
|
177
|
+
if (notFound && !ownNotFound && !hasPublicFile(config?.root, '404.html')) {
|
|
178
|
+
injectRoute({ pattern: '/404', entrypoint: 'ferst-core/routes/404.astro' });
|
|
179
|
+
}
|
|
180
|
+
// Which optional routes this site has, for the pages that link to them (the sitemap,
|
|
181
|
+
// the "page not found" page).
|
|
182
|
+
updateConfig?.({
|
|
183
|
+
vite: {
|
|
184
|
+
define: {
|
|
185
|
+
'import.meta.env.FERST_ROUTES_BLOG': JSON.stringify(blog),
|
|
186
|
+
'import.meta.env.FERST_ROUTES_CALENDAR': JSON.stringify(calendar),
|
|
187
|
+
'import.meta.env.FERST_ROUTES_ACCESSIBILITY': JSON.stringify(accessibility),
|
|
188
|
+
// Each of the site's own images with its width and height, so a page keeps every
|
|
189
|
+
// picture's shape before it loads (lib/image-sizes.ts).
|
|
190
|
+
'import.meta.env.FERST_IMAGE_SIZES': JSON.stringify(publicImageSizes(config?.root)),
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
// Search signals: the site's address and whether this deploy is the live site (the
|
|
195
|
+
// production branch) or a test copy, the same rule the CMS uses for its git-proxy.
|
|
196
|
+
if (seo) {
|
|
197
|
+
const root = config?.root;
|
|
198
|
+
search = seoContext({ siteMeta: readSiteMeta(root), branch: deploymentBranch(), env: process.env });
|
|
199
|
+
updateConfig?.({
|
|
200
|
+
...(search.siteUrl && !config?.site ? { site: search.siteUrl } : {}),
|
|
201
|
+
vite: {
|
|
202
|
+
define: {
|
|
203
|
+
'import.meta.env.FERST_SITE_URL': JSON.stringify(search.siteUrl ?? ''),
|
|
204
|
+
'import.meta.env.FERST_SEO_PRODUCTION': JSON.stringify(search.production),
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
if (!hasPublicFile(root, 'robots.txt')) {
|
|
209
|
+
injectRoute({ pattern: '/robots.txt', entrypoint: 'ferst-core/routes/robots.txt.ts' });
|
|
210
|
+
}
|
|
211
|
+
// A sitemap lists absolute addresses, so it needs the site's address.
|
|
212
|
+
if (search.siteUrl && !hasPublicFile(root, 'sitemap.xml')) {
|
|
213
|
+
injectRoute({ pattern: '/sitemap.xml', entrypoint: 'ferst-core/routes/sitemap.xml.ts' });
|
|
214
|
+
}
|
|
215
|
+
// The news feed lists absolute addresses too.
|
|
216
|
+
if (search.siteUrl && blog) {
|
|
217
|
+
injectRoute({ pattern: '/posts/rss.xml', entrypoint: 'ferst-core/routes/posts/rss.xml.ts' });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
// The engine's self-hosted fonts: served in dev, copied into every build.
|
|
222
|
+
'astro:server:setup': fonts['astro:server:setup'],
|
|
223
|
+
'astro:build:done': async (ctx) => {
|
|
224
|
+
await fonts['astro:build:done'](ctx);
|
|
225
|
+
// Internal links point at each page's one address, never at a redirect (lib/seo.mjs).
|
|
226
|
+
if (seo) {
|
|
227
|
+
const isPage = (path) => {
|
|
228
|
+
try {
|
|
229
|
+
return existsSync(new URL(`.${path}index.html`, ctx.dir));
|
|
230
|
+
} catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
for (const file of htmlFiles(ctx.dir)) {
|
|
235
|
+
const html = readFileSync(file, 'utf8');
|
|
236
|
+
const linked = linksToPageAddresses(html, isPage);
|
|
237
|
+
if (linked !== html) writeFileSync(file, linked);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// A test copy is noindex on every file: pages, and the PDFs and images beside them.
|
|
241
|
+
if (search && !search.production) {
|
|
242
|
+
const file = new URL('_headers', ctx.dir);
|
|
243
|
+
writeFileSync(file, withNoindexHeader(existsSync(file) ? readFileSync(file, 'utf8') : ''));
|
|
244
|
+
}
|
|
245
|
+
// The browser icon: /favicon.ico and /apple-touch-icon.png (sharp comes with Astro).
|
|
246
|
+
if (icons && siteRoot) {
|
|
247
|
+
const sharp = await import('sharp').then((m) => m.default ?? m).catch(() => null);
|
|
248
|
+
await writeSiteIcons({ root: siteRoot, outDir: ctx.dir, sharp, warn: (m) => (ctx.logger ? ctx.logger.warn(m) : console.warn(m)) });
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
package/layouts/Base.astro
CHANGED
|
@@ -79,8 +79,9 @@ const path = Astro.url.pathname;
|
|
|
79
79
|
// three source colours (light color-mix + dark OKLCH) and emits the font/knob
|
|
80
80
|
// overrides too; selectors are doubled (`:root:root`) so they win by
|
|
81
81
|
// specificity regardless of stylesheet order. `themeField` is the site-wide
|
|
82
|
-
// input treatment, applied as a `data-field` attribute on <html
|
|
83
|
-
|
|
82
|
+
// input treatment, applied as a `data-field` attribute on <html>; `titleEffect`
|
|
83
|
+
// the finish on display titles, a `data-title-effect` attribute (styles/theme.css).
|
|
84
|
+
const { css: themeCss, field: themeField, titleEffect } = buildThemeStyle(theme);
|
|
84
85
|
|
|
85
86
|
// Logos are optional. When a client hasn't configured one, SiteHeader renders a
|
|
86
87
|
// text wordmark (the site name) rather than pointing <img> at a baked-in path
|
|
@@ -137,7 +138,7 @@ const hasFeed = Boolean(siteUrl) && import.meta.env.FERST_ROUTES_BLOG !== false;
|
|
|
137
138
|
---
|
|
138
139
|
|
|
139
140
|
<!doctype html>
|
|
140
|
-
<html lang="en-GB" data-field={themeField}>
|
|
141
|
+
<html lang="en-GB" data-field={themeField} data-title-effect={titleEffect}>
|
|
141
142
|
<head>
|
|
142
143
|
<meta charset="utf-8" />
|
|
143
144
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
@@ -263,6 +264,7 @@ const hasFeed = Boolean(siteUrl) && import.meta.env.FERST_ROUTES_BLOG !== false;
|
|
|
263
264
|
headerClass={headerClass}
|
|
264
265
|
primaryLogoLight={primaryLogoLight}
|
|
265
266
|
primaryLogoDark={primaryLogoDark}
|
|
267
|
+
logoHeader={settings.header}
|
|
266
268
|
brandAlt={brandAlt}
|
|
267
269
|
primaryNav={navigation.primary}
|
|
268
270
|
dropdown={navigation.dropdown}
|
|
@@ -497,6 +499,9 @@ const hasFeed = Boolean(siteUrl) && import.meta.env.FERST_ROUTES_BLOG !== false;
|
|
|
497
499
|
flex-direction: column;
|
|
498
500
|
gap: clamp(2rem, 4vw, 3rem);
|
|
499
501
|
padding-block: clamp(3rem, 6vw, 5rem);
|
|
502
|
+
/* A header logo that hangs below the bar (--logo-overhang, SiteHeader) never sits
|
|
503
|
+
over the page's first words. */
|
|
504
|
+
padding-block-start: max(clamp(3rem, 6vw, 5rem), calc(var(--logo-overhang, 0px) + 1rem));
|
|
500
505
|
}
|
|
501
506
|
.site-main > * {
|
|
502
507
|
margin-block: 0;
|
|
@@ -508,6 +513,11 @@ const hasFeed = Boolean(siteUrl) && import.meta.env.FERST_ROUTES_BLOG !== false;
|
|
|
508
513
|
.site-main:has(> .b-banner[data-full-bleed='true']:first-child) {
|
|
509
514
|
padding-block-start: 0;
|
|
510
515
|
}
|
|
516
|
+
/* That flush opener keeps its words clear of a hanging header logo itself (Hero). */
|
|
517
|
+
.site-main > .b-hero[data-size='screen']:first-child,
|
|
518
|
+
.site-main > .b-hero[data-full-bleed='true']:first-child {
|
|
519
|
+
--hero-clear: calc(var(--logo-overhang, 0px) + 1.5rem);
|
|
520
|
+
}
|
|
511
521
|
|
|
512
522
|
/* ── Content alignment cascade ──────────────────────────────────────
|
|
513
523
|
A page sets its default alignment via the `align` prop (→
|