feat: expose font preloads in /sites/_hashes#128
Draft
BatLeDev wants to merge 1 commit into
Draft
Conversation
a2c7497 to
53ae2ba
Compare
The sites _hashes payload exposes a `fonts` list so portals and lib-served SPAs can emit `<link rel="preload">` for the site fonts before the theme stylesheet. - the preload URLs live in the theme (`bodyFontPreloadUrls` / `headingFontPreloadUrls`), populated by the portals manager for custom fonts. - each slot falls back to the configured default theme (Nunito) preload, mirroring getThemeCss, so a font is never preloaded unless it is used. - the mime type is derived from the URL extension and omitted when unknown.
53ae2ba to
4f84b96
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose a
fontslist inGET /sites/_hashesso SPA consumers (@data-fair/libserve-spa, the Nuxt portal) can emit<link rel="preload" as="font">and fetch site fonts in parallel with the theme stylesheet.What changed:
bodyFontPreloadUrls/headingFontPreloadUrlsarrays (new theme-schema fields, populated by the portals manager for custom fonts).getThemeFontPreloadsresolves{SITE_PATH}, dedupes, and derives the MIME type from the extension (omitted when unknown).getThemeCss: a slot uses the site's preload when it sets that font's CSS, otherwise the default theme's self-hosted Nunito preload — so a font is never preloaded unless it is actually rendered.GET /sites/_hashesnow also returnsfonts: [{ href, type? }](site and default branches).config.tsdrops the Nunito preload defaults when the operator configures a custom font viaTHEME_*, so they can't shadow it.Why: load fonts in parallel with the theme instead of waiting for
_theme.cssto fetch+parse, breaking the serial HTML →_theme.css→ woff2 chain.Regression risks:
_hashesgains an additivefontsfield; consumers tolerate its absence (?? []). No existing export signatures changed.bodyFontPreloadUrls/headingFontPreloadUrls, defined in @data-fair/lib (feat: site font preloads (theme schema + SPA injection) lib#40). A site without them (or without a custom font) falls back to the default Nunito preload; nothing breaks if they're absent.