Replace own custom fonts loader with Astro Fonts Api#351
Replace own custom fonts loader with Astro Fonts Api#351JopMolenaar wants to merge 9 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates font loading from a custom @fontsource-based loader to Astro’s (currently experimental) Fonts API, so the app’s primary layout and CMS editor guide use centrally configured fonts.
Changes:
- Adds an Astro Fonts configuration (
fontConfig) and wires it intoastro.config.tsviaexperimental.fonts. - Replaces the previous
define:varsfont family usage with a CSS variable (--font-archivo) and inserts the<Font />helper in relevant<head>sections. - Removes the custom font preload and
@font-faceinjection logic fromPerfHead.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
astro.config.ts |
Registers the new font configuration under experimental.fonts. |
src/assets/fonts.ts |
Replaces the custom loader/font-face helpers with an Astro Fonts API configuration. |
src/layouts/PerfHead/PerfHead.astro |
Removes custom font preloading and @font-face injection. |
src/layouts/Default.astro |
Injects the Astro <Font /> helper and switches global font-family to the new CSS variable. |
src/pages/cms/editor-guide.astro |
Injects the Astro <Font /> helper and switches font-family to the new CSS variable for the editor guide page. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying head-start with
|
| Latest commit: |
d067338
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://903354eb.head-start.pages.dev |
| Branch Preview URL: | https://feat-replace-own-custom-font.head-start.pages.dev |
decrek
left a comment
There was a problem hiding this comment.
This PR changes how fonts are loaded for the end user. Previously fonts were preloaded, but in the preview link the font face declarations are just inlined. I would say that this is worse than before regarding loading experience of fonts. At least it is different. If you want to just change how fonts are loaded, probably adding preload on the font is enough? See https://docs.astro.build/en/guides/fonts/#preloading-fonts. Im all for using this build in method btw, I just think the output should be the same
|
@decrek |
Changes
Associated issue
Resolves #350
How to test
Checklist