Skip to content

feat: expose theme preload links in /sites/_hashes#128

Merged
albanm merged 1 commit into
masterfrom
font-preloads-via-hashes
Jun 15, 2026
Merged

feat: expose theme preload links in /sites/_hashes#128
albanm merged 1 commit into
masterfrom
font-preloads-via-hashes

Conversation

@BatLeDev

@BatLeDev BatLeDev commented Jun 11, 2026

Copy link
Copy Markdown
Member

Expose a preloadLinks list in GET /sites/_hashes so SPA consumers (@data-fair/lib serve-spa, the Nuxt portal) can emit <link rel="preload"> and fetch a site's resources in parallel with the theme stylesheet.

What changed:

  • GET /sites/_hashes returns preloadLinks: [{ href, as?, type?, crossorigin? }] (renamed from fonts), taken straight from the theme's preloadLinks field (defined in @data-fair/lib, populated by the portals manager for custom fonts).
  • simple-directory is a plain relay: it forwards the theme's preloadLinks verbatim (or the default theme's when the site sets none). No dedup, no per-resource logic, no {SITE_PATH} templating — the producer (portals + default theme) builds the complete, final list.
  • config.ts drops the default Nunito link when the operator configures a custom body font via THEME_*.

Why: load a site's fonts (and tomorrow other resources like a logo) in parallel with the theme instead of waiting for _theme.css. Per review, SD does nothing but move the link list to where consumers need it.

Regression risks:

  • _hashes field renamed fontspreloadLinks; lib (feat: site resource preloads via theme schema and SPA injection lib#40, serve-spa) and portals (feat(portal): preload site fonts from sd _hashes portals#73) read the new key — deploy together.
  • Requires the matching @data-fair/lib-common-types release (theme preloadLinks with explicit href / as / type / crossorigin).
  • Dropped the previous per-slot fallback, dedup and {SITE_PATH} resolution — intentional; that logic now lives with the producer, and the default href is absolute now that sitePath is being deprecated.
  • Bumps @data-fair/lib-express ^1.19→^1.23 (and lib-node ^2.12.1→^2.13.1) — that's how the preloadLinks theme field reaches this service. The bump also changes pseudo-session behavior: non-GET requests on a pseudo session now return 403 instead of 401 (lib-express session.js). pseudo-session.api.spec.ts's keepalive assertion was updated to match; any external consumer keying on 401 for that case will now see 403.

@github-actions github-actions Bot added feature and removed feature labels Jun 11, 2026
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch 2 times, most recently from a2c7497 to 53ae2ba Compare June 12, 2026 08:22
@github-actions github-actions Bot added feature and removed feature labels Jun 12, 2026
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from 53ae2ba to 4f84b96 Compare June 12, 2026 08:42
@BatLeDev BatLeDev marked this pull request as ready for review June 15, 2026 07:33
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from 4f84b96 to 40dda6e Compare June 15, 2026 08:23
@github-actions github-actions Bot added feature and removed feature labels Jun 15, 2026
@BatLeDev BatLeDev changed the title feat: expose font preloads in /sites/_hashes feat: expose theme preload links in /sites/_hashes Jun 15, 2026
@github-actions github-actions Bot added feature and removed feature labels Jun 15, 2026
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from 40dda6e to 2590910 Compare June 15, 2026 09:14
@github-actions github-actions Bot added feature and removed feature labels Jun 15, 2026
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from 2590910 to 8123d5e Compare June 15, 2026 09:32
@github-actions github-actions Bot added feature and removed feature labels Jun 15, 2026
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch 2 times, most recently from b2c5302 to 599f4b9 Compare June 15, 2026 12:35
The sites _hashes payload exposes a `preloadLinks` list so portals and
lib-served SPAs can emit `<link rel="preload">` for a site's resources
before the theme stylesheet.

- simple-directory forwards the theme's `preloadLinks` verbatim (href + as /
  type / crossorigin) — a plain relay, no transform, no dedup, no logic.
- a site without its own `preloadLinks` falls back to the default theme's;
  `config.ts` drops the default link when the operator sets a custom body font.
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from 599f4b9 to 77aabc5 Compare June 15, 2026 15:49
@github-actions github-actions Bot added feature and removed feature labels Jun 15, 2026
@albanm albanm merged commit 6f281c4 into master Jun 15, 2026
4 checks passed
@albanm albanm deleted the font-preloads-via-hashes branch June 15, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants