fix(gatsby-source-contentful): Correct supported image formats#29562
fix(gatsby-source-contentful): Correct supported image formats#29562
Conversation
94cfe3e to
628edce
Compare
628edce to
2ce9ce4
Compare
wardpeet
left a comment
There was a problem hiding this comment.
I've added a small nit.
| // cache is more likely to go stale than the images (which never go stale) | ||
| // Note that the same image might be requested multiple times in the same run | ||
|
|
||
| const validImageFormats = new Set([`jpg`, `png`, `webp`]) |
There was a problem hiding this comment.
Not sure why a set is needed here.
| const validImageFormats = new Set([`jpg`, `png`, `webp`]) | |
| const validImageFormats = [`jpg`, `png`, `webp`] |
There was a problem hiding this comment.
I was under the impression that set.has was significantly faster than array.includes
There was a problem hiding this comment.
It probably is but it doesn't matter on a 3 items list. For me when I read Sets I expect things to get added to it and making sure things are unique and that makes it more complex in my head.
Sets are fine, that's why I approved it but wanted to get the reason on the why :)
There was a problem hiding this comment.
It's just a pattern I always use for this sort of check, particularly when dealing with potentially large numbers of nodes, with a constant Set.
| height = CONTENTFUL_IMAGE_MAX_SIZE | ||
| } | ||
|
|
||
| if (!validImageFormats.has(toFormat)) { |
There was a problem hiding this comment.
| if (!validImageFormats.has(toFormat)) { | |
| if (!validImageFormats.includes(toFormat)) { |
(cherry picked from commit 3b4d32f)
|
Published in |
Contentful doesn't support AVIF. This fixes the resolver, and adds a check in the url builder