diff --git a/packages/gatsby-remark-images-contentful/package.json b/packages/gatsby-remark-images-contentful/package.json index 4465203b94d73..00ac8116d7c33 100644 --- a/packages/gatsby-remark-images-contentful/package.json +++ b/packages/gatsby-remark-images-contentful/package.json @@ -33,6 +33,6 @@ "author": "Khaled Garbaya ", "license": "MIT", "peerDependencies": { - "gatsby": "^2.0.0" + "gatsby": "^2.0.15" } } diff --git a/packages/gatsby-remark-images-contentful/src/__tests__/index.js b/packages/gatsby-remark-images-contentful/src/__tests__/index.js index 87376ce5a3750..f093ecc237bc2 100644 --- a/packages/gatsby-remark-images-contentful/src/__tests__/index.js +++ b/packages/gatsby-remark-images-contentful/src/__tests__/index.js @@ -63,6 +63,7 @@ const createPluginOptions = (content, imagePaths = `/`) => { dir: dirName, } }, + createContentDigest: jest.fn().mockReturnValue(`contentDigest`), } } diff --git a/packages/gatsby-remark-images-contentful/src/index.js b/packages/gatsby-remark-images-contentful/src/index.js index 277ca77c1ecd3..744e2878b1d18 100644 --- a/packages/gatsby-remark-images-contentful/src/index.js +++ b/packages/gatsby-remark-images-contentful/src/index.js @@ -1,4 +1,3 @@ -const crypto = require(`crypto`) const select = require(`unist-util-select`) const sharp = require(`./safe-sharp`) const axios = require(`axios`) @@ -15,7 +14,16 @@ const { buildResponsiveSizes } = require(`./utils`) // 5. Set the html w/ aspect ratio helper. module.exports = async ( - { files, markdownNode, markdownAST, pathPrefix, getNode, reporter, cache }, + { + files, + markdownNode, + markdownAST, + pathPrefix, + getNode, + reporter, + cache, + createContentDigest, + }, pluginOptions ) => { const defaults = { @@ -50,10 +58,7 @@ module.exports = async ( const fileName = srcSplit[srcSplit.length - 1] const options = _.defaults(pluginOptions, defaults) - const optionsHash = crypto - .createHash(`md5`) - .update(JSON.stringify(options)) - .digest(`hex`) + const optionsHash = createContentDigest(options) const cacheKey = `remark-images-ctf-${fileName}-${optionsHash}` let cahedRawHTML = await cache.get(cacheKey)