-
Notifications
You must be signed in to change notification settings - Fork 61
chore: preload fonts #1018
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
base: main
Are you sure you want to change the base?
chore: preload fonts #1018
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@doc-kit/generator-react': patch | ||
| --- | ||
|
|
||
| Preload the theme's fonts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,20 @@ export const JSX_IMPORTS = { | |
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Where the bundler emits fonts | ||
| */ | ||
| export const FONT_DIRECTORY = 'assets/fonts'; | ||
|
|
||
| /** | ||
| * Fonts to preload | ||
| */ | ||
| export const FONTS = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we avoid doing static lists? Maybe a function that we define per font we need that creates the css block and the import and the loading like Next.ja?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do it that way, it's slower, since we need to minify the dynamically created HTML. This way we can do one minification pass
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it would be slower? 🤔
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, maybe you're not visualizing the idea: const [codeToAddToHead, fontFamilySnippet] = generateFontSnippet('open-sans-latin-wght-italic', ['woff']);fgirst argument being the font name, 2nd being the supported formats.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Each font has a different snippet, so that's not an option
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, each font has a different snippet. So you append instead of https://github.com/nodejs/doc-kit/pull/1018/changes#diff-71b846ed4741eff9604ce9e99abc324eb6dafbb8724dc337f6eefde00dae282aR10 Youll have ${fontOnePreload}
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is genuinely what Next.js does, annd makes maintainability much easier/reduces hard-coded pieces.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to do it like that. I'd prefer a Doing ${preloadA} ${preloadB} makes the template not very overrideable, should we add or remove fonts
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel we're at an impass 😅 -- I feel we should avoid hard-coded list of fonts and allow this to be customizable/used by the end-user rather than the way it is lied out currently.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw we need to reach consensus before RenderATL 🙈 |
||
| 'open-sans-latin-wght-normal.woff2', | ||
| 'open-sans-latin-wght-italic.woff2', | ||
| 'ibm-plex-mono-latin-400-normal.woff2', | ||
| ]; | ||
|
|
||
| /** | ||
| * Specification rules for resource hints like prerendering and prefetching. | ||
| * @see https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API | ||
|
|
||
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.
just ooc: how Next.js preloads fonts?