framework icon indicating copy to clipboard operation
framework copied to clipboard

An option to control the google font links

Open Fil opened this issue 1 year ago • 7 comments
trafficstars

The extraHead option allows to define an HTML fragment to add to the top of the page’s head. It defaults to the 3 links that allow to use the Source Serif Pro font from Google Fonts. (Prefer the head option, unless your goal is to remove or replace the default fonts.)

Note that its defaults will evolve once we self-host fonts (#423).

Fil avatar Aug 20 '24 09:08 Fil

Yes, for example here is the approach that vitepress supports: https://vitepress.dev/reference/site-config#example-adding-google-fonts

which I implemented in the companion PR for Plot here https://github.com/observablehq/plot/pull/2139/commits/071e9a19df5a8b2b08588cbaf397aa27595e0819

Fil avatar Aug 20 '24 10:08 Fil

Yes so maybe we just need an extraHead option that does both the preconnect and the stylesheet, and then we can remove both hardcoded references to Google Fonts?

mbostock avatar Aug 20 '24 11:08 mbostock

OK, I'll work on this, should be quick (but I don't think it's blocking for #1588).

Fil avatar Aug 20 '24 11:08 Fil

I've implemented extraHead but now I'm thinking that the only thing we need is a flag to cancel the three links, since we can implement the new fonts in the head option?

Fil avatar Aug 20 '24 12:08 Fil

Can you please re-merge main and resolve the conflicts? I can’t review this because it now includes a copy of all the other changes.

mbostock avatar Aug 20 '24 23:08 mbostock

I don't like the extra complexity, and suggest #1592 instead.

Fil avatar Aug 21 '24 08:08 Fil

I believe this is temporary, since #423 wants to detect and preload the default google font (if it's used).

(We'll probably have to move font definitions from global.css to font.css to make it possible to create a custom style.css that does not include the now unused import.)

My vote is to keep this private (and simple), #1595.

Fil avatar Aug 21 '24 12:08 Fil