Skip to content

Commit

Permalink
incorporate review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Mar 11, 2022
1 parent 2cfff49 commit e8c3ff3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/gatsby-plugin-sharp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ function calculateImageDimensionsAndAspectRatio(file, options) {

function prepareQueue({ file, args }) {
const { pathPrefix, duotone, ...rest } = args
const options = Object.assign(rest, duotone)
const argsDigestShort = createArgsDigest(options)
const imgSrc = `/${file.name}.${options.toFormat}`
// Duotone is a nested object inside transformOptions and has a [Object: Null Prototype]
// So it's flattened into a new object so that createArgsDigest also takes duotone into account
const digestArgs = Object.assign(rest, duotone)
const argsDigestShort = createArgsDigest(digestArgs)
const imgSrc = `/${file.name}.${args.toFormat}`
const outputDir = path.join(
process.cwd(),
`public`,
Expand All @@ -100,11 +102,11 @@ function prepareQueue({ file, args }) {

const { width, height, aspectRatio } = calculateImageDimensionsAndAspectRatio(
file,
options
args
)

// encode the file name for URL
const encodedImgSrc = `/${encodeURIComponent(file.name)}.${options.toFormat}`
const encodedImgSrc = `/${encodeURIComponent(file.name)}.${args.toFormat}`

// Prefix the image src.
const digestDirPrefix = `${file.internal.contentDigest}/${argsDigestShort}`
Expand Down

0 comments on commit e8c3ff3

Please sign in to comment.