Я хотел отформатировать свои внешние изображения, упомянутые в блогах по уценке, при копировании фрагмента кода из документации, например, следующего
https://www.gatsbyjs.org/docs/preprocessing-external-images/#gatsby -node
const { createRemoteFileNode } = require("gatsby-source-filesystem")
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions
createTypes(`
type MarkdownRemark implements Node {
frontmatter: Frontmatter
featuredImg: File @link(from: "featuredImg___NODE")
}
type Frontmatter {
title: String!
featuredImgPath: String
}
`)
}
exports.onCreateNode = async ({
node,
actions: { createNode },
store,
cache,
createNodeId,
}) => {
// For all MarkdownRemark nodes that have a featured image url, call createRemoteFileNode
if (
node.internal.type === "MarkdownRemark" &&
node.frontmatter.featuredImgPath !== null &&
!node.frontmatter.draft &&
node.frontmatter.isexternal
) {
console.log(node.frontmatter)
let fileNode = await createRemoteFileNode({
url: node.frontmatter.featuredImgPath, // string that points to the URL of the image
parentNodeId: node.id, // id of the parent node of the fileNode you are going to create
createNode, // helper function in gatsby-node to generate the node
createNodeId, // helper function in gatsby-node to generate the node id
cache, // Gatsby's cache
store, // Gatsby's redux store
})
// if the file was created, attach the new node to the parent node
if (fileNode) {
node.featuredImg___NODE = fileNode.id
}
}
}
При добавлении CreateNodes в соответствии с рекомендациями документации gatsby я получаю следующую ошибку:
UNHANDLED REJECTION Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
- api-runner-node-error-parser.js:39 errorParser
[portfolio2018]/[gatsby]/dist/utils/api-runner-node-error-parser.js:39:33
- api-runner-node.js:398
[portfolio2018]/[gatsby]/dist/utils/api-runner-node.js:398:29
- api-runner-node.js:340 async module.exports
[portfolio2018]/[gatsby]/dist/utils/api-runner-node.js:340:18