Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: try fontaine #305

Merged
merged 2 commits into from
Oct 16, 2022
Merged

feat: try fontaine #305

merged 2 commits into from
Oct 16, 2022

Conversation

johnnyreilly
Copy link
Owner

@johnnyreilly johnnyreilly commented Oct 16, 2022

Try out @danielroe's Fontaine: https://github.com/unjs/fontaine

If it works out I'd be happy to contribute Docusaurus usage docs to the project as per unjs/fontaine#7

Baseline

Here's my blog in mobile mode right now (to be clear; this is live - the baseline):

what it looks like now - not great

I've added Fontaine

I'm using Docusaurus and I'm kind of guessing what implementation should be; I could be have a borked approach.

When I browse to https://thankful-sky-0bfc7e803-305.westeurope.1.azurestaticapps.net/ it doesn't seem to work. Probably doing something wrong. It looks like this:

after-applying-it

According to the Lighthouse report:

Cumulative Layout Shift
0.019

Why do I think it doesn't work?

Well essentially it's the word width thing. On the first line we either see:

Fallback font: "Bicep: Static Web Apps" [four words on one line]

OR

Custom font (Poppins): "Bicep: Static Web" [three words on one line]

I would expect the fallback font to also be displaying "Bicep: Static Web"; fitting the same amount on a single line.

So maybe I'm doing something wrong.

Things I could be doing wrong

  • I'm using Docusaurus and I've implemented this using a custom plugin. I think this is probably the correct pattern - but I've invented this just now; as there isn't a "docusaurus way" documented
  • I host my fonts on my site, I don't load them from a CDN. I also preload them with a webpack plugin. I'm unsure if this is something that plays well with Fontaine - the docs seem to talk more about loading from a CDN. Not sure.
  • I'm doing this to resolve fonts: resolvePath: (id) => '../fonts/' + id, . Not sure if this is correct, I copy pasted from custom.css. There you'll see code like this: src: url('../fonts/Poppins-Regular.ttf'); - which made me thinkI needed to specify ../fonts/ for each font. Is this right? Dunno. No errors in the console that I can see. Unsure how to debug.

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-sky-0bfc7e803-305.westeurope.1.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Oct 16, 2022

⚡️🏠 Lighthouse report

We ran Lighthouse against the changes and produced this report. Here's the summary:

Category Score
🔴 Performance 47
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 98
🟢 PWA 100

Lighthouse ran against https://thankful-sky-0bfc7e803-305.westeurope.1.azurestaticapps.net/

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-sky-0bfc7e803-305.westeurope.1.azurestaticapps.net

@johnnyreilly
Copy link
Owner Author

johnnyreilly commented Oct 16, 2022

I think it might work! (it's all on the same line)

Cumulative Layout Shift: 0

working

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.

2 participants