Skip to content

feat: site font preloads (theme schema + SPA injection)#40

Draft
BatLeDev wants to merge 2 commits into
mainfrom
font-preloads-via-hashes
Draft

feat: site font preloads (theme schema + SPA injection)#40
BatLeDev wants to merge 2 commits into
mainfrom
font-preloads-via-hashes

Conversation

@BatLeDev

@BatLeDev BatLeDev commented Jun 11, 2026

Copy link
Copy Markdown
Member

Two parts of the site-font-preload feature:

  1. common-types — add bodyFontPreloadUrls / headingFontPreloadUrls (string arrays, layout: 'none') to the theme schema, plus the self-hosted Nunito default in defaultTheme. These declare which font files a theme wants preloaded.
  2. express (serve-spa) — inject <link rel="preload" as="font"> into served SPA index.html from the fonts list returned by simple-directory's /sites/_hashes, spliced before the _theme.css link, so fonts download in parallel with the theme. Interpolated attribute values are HTML-escaped (the href originates from site-configured theme data).

Why: break the serial HTML → _theme.css → woff2 chain by preloading fonts in parallel. Producer side: data-fair/simple-directory#128.

Regression risks:

  • defaultTheme gains bodyFontPreloadUrls (Nunito); additive, only read by the preload logic.
  • SPA injection is active only when privateDirectoryUrl is set and SD returns fonts; tolerates absence (?? []), so no change against an older simple-directory, and a no-op when index.html has no _theme.css link.

Note — unrelated commit: this branch also carries fix(lib-common-types): simplify the assistedMode reset warning wording (i18n text only, six locales). It's independent of the font feature — split into its own PR if you'd rather keep this one single-purpose.

@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from a105cbe to cbbc68a Compare June 11, 2026 14:40
BatLeDev added 2 commits June 12, 2026 10:21
- add `bodyFontPreloadUrls` / `headingFontPreloadUrls` to the theme schema and
  the self-hosted Nunito default to defaultTheme.
- inject `<link rel="preload">` font links into the served SPA html from the
  sites _hashes payload, with an optional (extension-derived) mime type.
Drop the "détaillées … en mode avancé" phrasing in favour of the shorter
"couleurs avancées définies manuellement", in all six locales.
@BatLeDev BatLeDev force-pushed the font-preloads-via-hashes branch from cbbc68a to 6627681 Compare June 12, 2026 08:22
@BatLeDev BatLeDev changed the title feat(lib-express): inject font preload links in served SPA html feat: site font preloads (theme schema + SPA injection) Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant