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.
Files changed (62) hide show
  1. package/README.md +13 -4
  2. package/bin/ferst-media.mjs +96 -0
  3. package/cms/config.template.yml +11 -0
  4. package/components/Card.astro +53 -51
  5. package/components/PostCard.astro +138 -136
  6. package/components/SiteHeader.astro +1356 -1273
  7. package/components/blocks/Grid.astro +49 -48
  8. package/components/blocks/Heading.astro +4 -1
  9. package/components/recipes/Banner.astro +146 -146
  10. package/components/recipes/Book.astro +39 -4
  11. package/components/recipes/FeatureCards.astro +112 -118
  12. package/components/recipes/Gallery.astro +57 -59
  13. package/components/recipes/Hero.astro +638 -533
  14. package/components/recipes/LatestPosts.astro +295 -292
  15. package/components/recipes/Locations.astro +146 -143
  16. package/components/recipes/Marquee.astro +75 -75
  17. package/components/recipes/MediaCards.astro +213 -219
  18. package/components/recipes/Pricing.astro +149 -150
  19. package/components/recipes/Stats.astro +150 -157
  20. package/components/recipes/Tiles.astro +342 -296
  21. package/content/blocks.ts +1072 -1024
  22. package/content/imageSlots.mjs +542 -0
  23. package/content/schemas.ts +35 -2
  24. package/examples/recipes.ts +4 -0
  25. package/fonts/OFL.txt +1332 -287
  26. package/fonts/anton-latin-400-normal.woff2 +0 -0
  27. package/fonts/bangers-latin-400-normal.woff2 +0 -0
  28. package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
  29. package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
  30. package/fonts/fredoka-latin-400-normal.woff2 +0 -0
  31. package/fonts/fredoka-latin-600-normal.woff2 +0 -0
  32. package/fonts/fredoka-latin-700-normal.woff2 +0 -0
  33. package/fonts/knewave-latin-400-normal.woff2 +0 -0
  34. package/fonts/lora-latin-400-normal.woff2 +0 -0
  35. package/fonts/lora-latin-600-normal.woff2 +0 -0
  36. package/fonts/lora-latin-700-normal.woff2 +0 -0
  37. package/fonts/merriweather-latin-400-normal.woff2 +0 -0
  38. package/fonts/merriweather-latin-600-normal.woff2 +0 -0
  39. package/fonts/merriweather-latin-700-normal.woff2 +0 -0
  40. package/fonts/nunito-latin-400-normal.woff2 +0 -0
  41. package/fonts/nunito-latin-600-normal.woff2 +0 -0
  42. package/fonts/nunito-latin-700-normal.woff2 +0 -0
  43. package/fonts/oswald-latin-400-normal.woff2 +0 -0
  44. package/fonts/oswald-latin-600-normal.woff2 +0 -0
  45. package/fonts/oswald-latin-700-normal.woff2 +0 -0
  46. package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
  47. package/integration.mjs +253 -249
  48. package/layouts/Base.astro +13 -3
  49. package/lib/book.ts +94 -1
  50. package/lib/fonts.ts +130 -0
  51. package/lib/gridRows.ts +197 -0
  52. package/lib/image-fields.ts +140 -0
  53. package/lib/image-size.mjs +108 -0
  54. package/lib/image-sizes.ts +16 -0
  55. package/lib/logo-header.ts +46 -0
  56. package/lib/media-check.mjs +524 -0
  57. package/lib/theme-preview.ts +203 -140
  58. package/lib/themeTokens.ts +235 -220
  59. package/package.json +3 -2
  60. package/styles/fonts.css +239 -76
  61. package/styles/theme.css +228 -160
  62. package/lib/gridColumns.ts +0 -22
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
- /** Every page of a build (its .html files, at any depth), as file URLs. */
53
- function htmlFiles(dir) {
54
- return readdirSync(dir, { withFileTypes: true }).flatMap((entry) =>
55
- entry.isDirectory()
56
- ? htmlFiles(new URL(`${encodeURIComponent(entry.name)}/`, dir))
57
- : entry.name.endsWith('.html')
58
- ? [new URL(encodeURIComponent(entry.name), dir)]
59
- : [],
60
- );
61
- }
62
-
63
- /** The self-hosted fonts the engine's CSS requests (/fonts/*.woff2), shipped in the package. */
64
- const FONTS_DIR = new URL('./fonts/', import.meta.url);
65
- const FONT_URL = /^\/fonts\/([a-z0-9-]+\.woff2)(?:\?.*)?$/;
66
-
67
- /**
68
- * ferstFonts() — serves the engine's self-hosted fonts in `astro dev` and copies them into
69
- * every build's `/fonts/`. Included in ferst(); usable on its own (the showcase). A file
70
- * the site already has in its own `public/fonts/` is never overwritten.
71
- * @returns {import('astro').AstroIntegration}
72
- */
73
- export function ferstFonts() {
74
- return {
75
- name: 'ferst-fonts',
76
- hooks: {
77
- 'astro:server:setup': ({ server }) => {
78
- server.middlewares.use((req, res, next) => {
79
- const m = req.url && req.url.match(FONT_URL);
80
- if (!m) return next();
81
- const file = new URL(m[1], FONTS_DIR);
82
- if (!existsSync(file)) return next();
83
- res.setHeader('Content-Type', 'font/woff2');
84
- res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
85
- createReadStream(file).pipe(res);
86
- });
87
- },
88
- 'astro:build:done': async ({ dir }) => {
89
- const out = new URL('fonts/', dir);
90
- mkdirSync(out, { recursive: true });
91
- for (const name of readdirSync(FONTS_DIR)) {
92
- if (!name.endsWith('.woff2')) continue;
93
- const dest = new URL(name, out);
94
- if (!existsSync(dest)) copyFileSync(new URL(name, FONTS_DIR), dest);
95
- }
96
- },
97
- },
98
- };
99
- }
100
-
101
- /** The site's `ferst-site.json`, or null (no file, or not JSON). */
102
- function readSiteMeta(root) {
103
- if (!root) return null;
104
- try {
105
- return JSON.parse(readFileSync(new URL('ferst-site.json', root), 'utf8'));
106
- } catch {
107
- return null;
108
- }
109
- }
110
-
111
- /** Does the site ship this file in its own `public/`? (Its own file wins over ours.) */
112
- const hasPublicFile = (root, name) => Boolean(root) && existsSync(new URL(`public/${name}`, root));
113
-
114
- export default function ferst(options = {}) {
115
- const { calendar = true, blog = true, cookiePolicy = true, accessibility = true, notFound = true, icons = true, seo = true } = options;
116
- const fonts = ferstFonts().hooks;
117
- /** This build's search context, decided at setup and used again when the build is done. */
118
- let search = null;
119
- /** The site's folder, for the content and public files the build-done steps read. */
120
- let siteRoot = null;
121
- return {
122
- name: 'ferst',
123
- hooks: {
124
- 'astro:config:setup': ({ injectRoute, updateConfig, config }) => {
125
- siteRoot = config?.root ?? null;
126
- // Pages + home: the reserved `index` entry renders at `/`, every other
127
- // `pages` entry at its own slug (see lib/pages.ts `getSiteRoutes`).
128
- injectRoute({
129
- pattern: '/[...slug]',
130
- entrypoint: 'ferst-core/routes/[...slug].astro',
131
- });
132
- if (calendar) {
133
- injectRoute({
134
- pattern: '/calendar',
135
- entrypoint: 'ferst-core/routes/calendar/index.astro',
136
- });
137
- }
138
- if (blog) {
139
- // The posts capability: index, individual post, and tag pages. Reads
140
- // the `posts`/`tags`/`postsSettings` collections (content/collections.ts).
141
- injectRoute({
142
- pattern: '/posts',
143
- entrypoint: 'ferst-core/routes/posts/index.astro',
144
- });
145
- injectRoute({
146
- pattern: '/posts/[...slug]',
147
- entrypoint: 'ferst-core/routes/posts/[...slug].astro',
148
- });
149
- injectRoute({
150
- pattern: '/posts/tag/[...tag]',
151
- entrypoint: 'ferst-core/routes/posts/tag/[...tag].astro',
152
- });
153
- // Index pages 2+ (page 1 is /posts; tag pages paginate inside their own route).
154
- injectRoute({
155
- pattern: '/posts/page/[page]',
156
- entrypoint: 'ferst-core/routes/posts/page/[page].astro',
157
- });
158
- }
159
- // The cookie banner links here on every page, so it must always resolve. A site's
160
- // own hand-built page wins (Astro would otherwise see two routes for one path).
161
- const bespoke = config?.root && existsSync(new URL('src/pages/cookie-policy.astro', config.root));
162
- if (cookiePolicy && !bespoke) {
163
- injectRoute({
164
- pattern: '/cookie-policy',
165
- entrypoint: 'ferst-core/routes/cookie-policy.astro',
166
- });
167
- }
168
- // Every footer links to the accessibility statement. The site's own page wins.
169
- const ownStatement = config?.root && existsSync(new URL('src/pages/accessibility.astro', config.root));
170
- if (accessibility && !ownStatement) {
171
- injectRoute({ pattern: '/accessibility', entrypoint: 'ferst-core/routes/accessibility.astro' });
172
- }
173
- // A missing address must answer 404, not the home page (Cloudflare Pages serves the
174
- // home page with a 200 when a build has no 404.html). The site's own page wins.
175
- const ownNotFound = config?.root && existsSync(new URL('src/pages/404.astro', config.root));
176
- if (notFound && !ownNotFound && !hasPublicFile(config?.root, '404.html')) {
177
- injectRoute({ pattern: '/404', entrypoint: 'ferst-core/routes/404.astro' });
178
- }
179
- // Which optional routes this site has, for the pages that link to them (the sitemap,
180
- // the "page not found" page).
181
- updateConfig?.({
182
- vite: {
183
- define: {
184
- 'import.meta.env.FERST_ROUTES_BLOG': JSON.stringify(blog),
185
- 'import.meta.env.FERST_ROUTES_CALENDAR': JSON.stringify(calendar),
186
- 'import.meta.env.FERST_ROUTES_ACCESSIBILITY': JSON.stringify(accessibility),
187
- },
188
- },
189
- });
190
- // Search signals: the site's address and whether this deploy is the live site (the
191
- // production branch) or a test copy, the same rule the CMS uses for its git-proxy.
192
- if (seo) {
193
- const root = config?.root;
194
- search = seoContext({ siteMeta: readSiteMeta(root), branch: deploymentBranch(), env: process.env });
195
- updateConfig?.({
196
- ...(search.siteUrl && !config?.site ? { site: search.siteUrl } : {}),
197
- vite: {
198
- define: {
199
- 'import.meta.env.FERST_SITE_URL': JSON.stringify(search.siteUrl ?? ''),
200
- 'import.meta.env.FERST_SEO_PRODUCTION': JSON.stringify(search.production),
201
- },
202
- },
203
- });
204
- if (!hasPublicFile(root, 'robots.txt')) {
205
- injectRoute({ pattern: '/robots.txt', entrypoint: 'ferst-core/routes/robots.txt.ts' });
206
- }
207
- // A sitemap lists absolute addresses, so it needs the site's address.
208
- if (search.siteUrl && !hasPublicFile(root, 'sitemap.xml')) {
209
- injectRoute({ pattern: '/sitemap.xml', entrypoint: 'ferst-core/routes/sitemap.xml.ts' });
210
- }
211
- // The news feed lists absolute addresses too.
212
- if (search.siteUrl && blog) {
213
- injectRoute({ pattern: '/posts/rss.xml', entrypoint: 'ferst-core/routes/posts/rss.xml.ts' });
214
- }
215
- }
216
- },
217
- // The engine's self-hosted fonts: served in dev, copied into every build.
218
- 'astro:server:setup': fonts['astro:server:setup'],
219
- 'astro:build:done': async (ctx) => {
220
- await fonts['astro:build:done'](ctx);
221
- // Internal links point at each page's one address, never at a redirect (lib/seo.mjs).
222
- if (seo) {
223
- const isPage = (path) => {
224
- try {
225
- return existsSync(new URL(`.${path}index.html`, ctx.dir));
226
- } catch {
227
- return false;
228
- }
229
- };
230
- for (const file of htmlFiles(ctx.dir)) {
231
- const html = readFileSync(file, 'utf8');
232
- const linked = linksToPageAddresses(html, isPage);
233
- if (linked !== html) writeFileSync(file, linked);
234
- }
235
- }
236
- // A test copy is noindex on every file: pages, and the PDFs and images beside them.
237
- if (search && !search.production) {
238
- const file = new URL('_headers', ctx.dir);
239
- writeFileSync(file, withNoindexHeader(existsSync(file) ? readFileSync(file, 'utf8') : ''));
240
- }
241
- // The browser icon: /favicon.ico and /apple-touch-icon.png (sharp comes with Astro).
242
- if (icons && siteRoot) {
243
- const sharp = await import('sharp').then((m) => m.default ?? m).catch(() => null);
244
- await writeSiteIcons({ root: siteRoot, outDir: ctx.dir, sharp, warn: (m) => (ctx.logger ? ctx.logger.warn(m) : console.warn(m)) });
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
+ }
@@ -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
- const { css: themeCss, field: themeField } = buildThemeStyle(theme);
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 (→