diff --git a/packages/gatsby-transformer-screenshot/lambda/index.js b/packages/gatsby-transformer-screenshot/lambda/index.js index 3bb3a76d1b092..31f6fe3ecc4e7 100644 --- a/packages/gatsby-transformer-screenshot/lambda/index.js +++ b/packages/gatsby-transformer-screenshot/lambda/index.js @@ -1,6 +1,6 @@ const setup = require(`./starter-kit/setup`) -const crypto = require(`crypto`) +const { createContentDigest } = require(`gatsby-core-utils`) const AWS = require(`aws-sdk`) const s3 = new AWS.S3({ @@ -55,12 +55,8 @@ exports.run = async (browser, url, width, height, fullPage) => { throw new Error(`invalid bucket ${process.env.S3_BUCKET}`) } - const keyBase = `${url}-(${width},${height})` - const digest = crypto - .createHash(`md5`) - .update(keyBase) - .digest(`hex`) - const key = `${digest}.png` + const contentDigest = createContentDigest({ url, width, height }) + const key = `${contentDigest}.png` const screenshotUrl = `https://s3-${region}.amazonaws.com/${ process.env.S3_BUCKET diff --git a/packages/gatsby-transformer-screenshot/lambda/package.json b/packages/gatsby-transformer-screenshot/lambda/package.json index 3aecab643c8d9..68c34e200cf32 100644 --- a/packages/gatsby-transformer-screenshot/lambda/package.json +++ b/packages/gatsby-transformer-screenshot/lambda/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "gatsby-core-utils": "^1.0.15", "puppeteer": "0.13.0", "tar": "^4.4.13" }, @@ -9,4 +10,4 @@ "keywords": [ "gatsby-plugin" ] -} \ No newline at end of file +}