Description
I used the plugin and observed, that in some HTML files the preload links for the fonts were missing.
Then I saw, that in font-preload-cache.json, some routes contain a trailing slash, but I generate all my pages without a trailing slash. For those routes, the lookup in the asset map fails.
|
if (!cache.assets[pathname]) return |
This could be replaced with
const assetsOfPath = cache.assets[pathname] ? cache.assets[pathname] : cache.assets[pathname + "/"]
if (!assetsOfPath) {
return
}
const assets = Object.keys(assetsOfPath)
Steps to reproduce
Generate some pages at paths with no trailing slashes. I am not sure why sometimes paths are written with trailing slashes and sometimes not in font-preload-cache.json. However, if that happens, lookups will fail in onRenderBody.
Expected result
Preload links should be written in all HTML files with a path match , independent of trailing slashes
Actual result
Preload links are not written in HTML files with a non-trailing-slash path, if asset map contains the same path with a trailing slash as a key for the assets
Description
I used the plugin and observed, that in some HTML files the preload links for the fonts were missing.
Then I saw, that in
font-preload-cache.json, some routes contain a trailing slash, but I generate all my pages without a trailing slash. For those routes, the lookup in the asset map fails.gatsby/packages/gatsby-plugin-preload-fonts/src/gatsby-ssr.js
Line 22 in f585eb0
This could be replaced with
Steps to reproduce
Generate some pages at paths with no trailing slashes. I am not sure why sometimes paths are written with trailing slashes and sometimes not in
font-preload-cache.json. However, if that happens, lookups will fail inonRenderBody.Expected result
Preload links should be written in all HTML files with a path match , independent of trailing slashes
Actual result
Preload links are not written in HTML files with a non-trailing-slash path, if asset map contains the same path with a trailing slash as a key for the assets