diff --git a/packages/gatsby-source-shopify/README.md b/packages/gatsby-source-shopify/README.md index 820d33266442d..3c350ddabb08f 100644 --- a/packages/gatsby-source-shopify/README.md +++ b/packages/gatsby-source-shopify/README.md @@ -72,6 +72,9 @@ plugins: [ // Possible values are: 'shop' and 'content'. // Defaults to ['shop', 'content']. includeCollections: ["shop", "content"], + // Download Images Locally + // set to false if you plan on using shopify's CDN + downloadImages: true, // Allow overriding the default queries // This allows you to include/exclude extra fields when sourcing nodes diff --git a/packages/gatsby-source-shopify/src/gatsby-node.js b/packages/gatsby-source-shopify/src/gatsby-node.js index b148b7559dc49..171a5606637d9 100644 --- a/packages/gatsby-source-shopify/src/gatsby-node.js +++ b/packages/gatsby-source-shopify/src/gatsby-node.js @@ -56,6 +56,7 @@ export const sourceNodes = async ( verbose = true, paginationSize = 250, includeCollections = [SHOP, CONTENT], + downloadImages = true, shopifyQueries = {}, } ) => { @@ -89,6 +90,7 @@ export const sourceNodes = async ( cache, getCache, reporter, + downloadImages, } // Arguments used for node creation. diff --git a/packages/gatsby-source-shopify/src/nodes.js b/packages/gatsby-source-shopify/src/nodes.js index 2c038e43b9389..a1799334fc541 100644 --- a/packages/gatsby-source-shopify/src/nodes.js +++ b/packages/gatsby-source-shopify/src/nodes.js @@ -24,15 +24,24 @@ const { createNodeFactory, generateNodeId } = createNodeHelpers({ const downloadImageAndCreateFileNode = async ( { url, nodeId }, - { createNode, createNodeId, touchNode, store, cache, getCache, reporter } + { + createNode, + createNodeId, + touchNode, + store, + cache, + getCache, + reporter, + downloadImages, + } ) => { - let fileNodeID + if (!downloadImages) return undefined const mediaDataCacheKey = `${TYPE_PREFIX}__Media__${url}` const cacheMediaData = await cache.get(mediaDataCacheKey) if (cacheMediaData) { - fileNodeID = cacheMediaData.fileNodeID + const fileNodeID = cacheMediaData.fileNodeID touchNode({ nodeId: fileNodeID }) return fileNodeID } @@ -49,7 +58,7 @@ const downloadImageAndCreateFileNode = async ( }) if (fileNode) { - fileNodeID = fileNode.id + const fileNodeID = fileNode.id await cache.set(mediaDataCacheKey, { fileNodeID }) return fileNodeID }