-
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
Nuxt Fonts not loading in Histoire #240
Comments
Hey there, @davestewart! I'm here to help you out with any bugs, questions, or becoming a contributor! Let's dig into this issue together and figure out what's going on. 🤖 The issue with Google fonts not loading in Histoire after upgrading to Nuxt Fonts, resulting in "Failed to decode downloaded font" errors, is likely due to the way Nuxt Fonts processes and serves the fonts. Here are some steps to resolve this issue:
Additionally, ensure that the font metadata is correctly fetched and cached. The import { hash } from 'ohash'
import { cachedData } from '../cache'
import { $fetch } from '../fetch'
import { logger } from '../logger'
const fontAPI = $fetch.create({
baseURL: 'https://api.fontsource.org/v1',
})
async function initialiseFontMeta() {
const fonts = await cachedData('fontsource:meta.json', () => fontAPI('/fonts', { responseType: 'json' }), {
onError() {
logger.error('Could not download `fontsource` font metadata. `@nuxt/fonts` will not be able to inject `@font-face` rules for fontsource.')
return {}
},
})
// Additional initialization logic...
}
async function getFontDetails(family, variants) {
const fontDetail = await fontAPI(`/fonts/${family}`, { responseType: 'json' })
// Process and return font details...
} By ensuring that these steps are correctly implemented and that the font metadata is properly fetched and cached, you should be able to resolve the font decoding errors [1][2][3]. Additionally, there is a similar open issue regarding fonts not loading correctly, which might provide further insights: Adding fonts like "Quiksand" and "Urbanist" fails [4]. |
This is an interesting one. |
We upgraded a few weeks ago to Nuxt Fonts from Nuxt Google Fonts but noticed today our Google fonts are not served in Histoire:
The Network response is actually HTML, and the Histoire index page itself:
This is the change in requests from package to package:
The only other special thing is that our project uses NX as a monorepo.
Any ideas?
The text was updated successfully, but these errors were encountered: