Skip to content

Commit

Permalink
chore: update using-image-processing example (#36421)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Aug 19, 2022
1 parent b361081 commit 240dfac
Showing 1 changed file with 7 additions and 14 deletions.
@@ -1,27 +1,20 @@
const { createRemoteFileNode } = require(`gatsby-source-filesystem`)

exports.onCreateNode = async (
{
actions: { createNode },
node,
createContentDigest,
store,
cache,
reporter,
},
{ filter, nodeName = `localFile` }
{ actions: { createNode, createNodeField }, node, createNodeId, getCache },
{ filter }
) => {
if (filter(node)) {
const fileNode = await createRemoteFileNode({
url: node.url,
cache,
parentNodeId: node.id,
getCache,
createNode,
createNodeId: createContentDigest,
createNodeId,
})

if (fileNode) {
const fileNodeLink = `${nodeName}___NODE`
node[fileNodeLink] = fileNode.id
createNodeField({ node, name: "localFile", value: fileNode.id })
}
}
}
Expand All @@ -35,7 +28,7 @@ exports.createSchemaCustomization = ({ actions }) => {
title: String
credit: String
gallery: Boolean
localFile: File @link(from: "localFile___NODE")
localFile: File @link(from: "fields.localFile")
}
`)
Expand Down

0 comments on commit 240dfac

Please sign in to comment.