-
Notifications
You must be signed in to change notification settings - Fork 7
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
@font-face
not used with fontshare
provider
#182
Comments
Hey there, @samk-dev! I'm here to help you with any bugs, questions, or contributions you might have. Let's tackle this issue together! To ensure that it('generates inlined font face rules for `fontshare` provider', async () => {
const html = await $fetch<string>('/providers/fontshare')
expect(extractFontFaces('Satoshi', html)).toMatchInlineSnapshot(`
[
"@font-face{font-family:Satoshi;src:local("Satoshi Regular"),local("Satoshi"),url(/_fonts/file.woff2) format(woff2),url(/_fonts/file.woff) format(woff),url(/_fonts/file.ttf) format(truetype);font-display:swap;font-weight:400;font-style:normal}",
]
`)
}) This test ensures that the Additionally, the By ensuring that these functions are correctly implemented and the test case passes, you can be confident that |
Would you be able to provide a reproduction? 🙏 More infoWhy do I need to provide a reproduction?Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. What will happen?If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If How can I create a reproduction?We have a template for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/fonts/tree/main/example A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as minimal as possible. See more details in our guide. You might also find these other articles interesting and/or helpful: |
@font-face
not used with fontshare
provider
Hey Daniel, here's a reproduction. reproduction I haven't tested if the issue persists after the released of an update to the module 2h ago. Let me know if you need me test anything else on my end. Thanks |
To address the issue with
Here is a snippet of the relevant code for initializing font metadata and generating async function initialiseFontMeta() {
fonts = await cachedData('fontshare:meta.json', async () => {
const fonts: FontshareFontMeta[] = []
let offset = 0
let chunk
do {
chunk = await fontAPI<{ fonts: FontshareFontMeta[], has_more: boolean }>('/fonts', {
responseType: 'json',
query: {
offset,
limit: 100,
},
})
fonts.push(...chunk.fonts)
offset++
} while (chunk.has_more)
return fonts
}, {
onError() {
logger.error('Could not download `fontshare` font metadata. `@nuxt/fonts` will not be able to inject `@font-face` rules for fontshare.')
return []
},
})
for (const font of fonts) {
families.add(font.name)
}
} If the issue persists, you can also try adding the Please test these steps and let me know if the issue is resolved or if further assistance is needed. |
@samk-dev checking this out, it seems the problem is that you aren't using the font anywhere in your app. So by adding the CSS + specifying it should be preloaded, you're asking the browser to add a preload for a font that isn't needed. Maybe I'm misunderstanding - so please do let me know more details and I'll happily reopen. |
I am using the module with
fontshare
as a provider. When checkingpageInsights
it shows that@font-face
is not being used. When addingfontain
module it resolves the issue.when using
fontain
Darwin
v20.14.0
3.12.2
3.12.0
2.9.6
[email protected]
-
devtools
,future
,modules
,runtimeConfig
,app
,routeRules
,devServer
,build
,fonts
,tailwindcss
@nuxt/[email protected]
,@nuxtjs/[email protected]
,@nuxt/[email protected]
,@nuxt/[email protected]
,@nuxtjs/[email protected]
-
The text was updated successfully, but these errors were encountered: