-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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(fonts): allow PageTitle to have its own font subset #1848
feat(fonts): allow PageTitle to have its own font subset #1848
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make title optional and just edit googleFontHref to optionally include that font if title is defined instead of making a new googleSubFontHref func
It can be done using one single googleFontHref function.
If the title is not defined, it falls back to TBD: Some might apply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah didnt notice the &text specifier, in that case lets just use the old 2 function approach
my only change request is to make the title param optional and default it to header
1f42f34
to
e2ba7f0
Compare
…elixnie/quartz into feat/pagetitle-font-subsetting
For example, when the title is undefined or manually set to be the same as the header, fetching a subset again is unnecessary. Title font should have identical For backward compatibility, title can be:
And the header font will be applied instead. |
can we use the two function approach in the first few commits? |
Sure. Do you have any further ideas about this? |
quartz/components/Head.tsx
Outdated
@@ -45,6 +45,7 @@ export default (() => { | |||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | |||
<link rel="preconnect" href="https://fonts.gstatic.com" /> | |||
<link rel="stylesheet" href={googleFontHref(cfg.theme)} /> | |||
<link rel="stylesheet" href={googleFontSubsetHref(cfg.theme, cfg.pageTitle)} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exclude the subset if title font is not explicitly defined (as it will just use header anyways)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent I added if-logic to both Head.tsx and componentResources.ts. Pls check the latest commit.
quartz.config.ts
Outdated
@@ -23,6 +23,7 @@ const config: QuartzConfig = { | |||
fontOrigin: "googleFonts", | |||
cdnCaching: true, | |||
typography: { | |||
title: "Playwrite DK Loopet", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final nit: lets remove this in the actual config, i like our existing header font
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Default config restored.
For the header
font to apply, title
can be:
- absent in config
""
undefined
awesome thanks! last thing, can you update the doc page for configuration? https://quartz.jzhao.xyz/configuration |
Okay! And there are some minor changes in formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, just make sure you run npm run format
so that the linter is happy
Ahh, no wonder the check keeps failing. Thanks. |
Subsetting fonts based on characters in pageTitle, so that we can have better branding without overloading unnecessary fonts.
Tested:
Demo:
https://draftz.felixnie.com/