Я использовал локальные файлы .md для уровня данных Gatsby, но теперь мне нужна интеграция с Contentful CMS.
const Promise = require('bluebird')
const path = require('path')
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
const blogPost = path.resolve('./src/templates/blog-post.js')
resolve(
graphql(
`
{
allContentfulBlog(limit: 500) {
edges {
node {
id
slug
}
}
}
}
`
).then(result => {
if (result.errors) {
console.log(result.errors)
reject(result.errors)
}
result.data.allContentfulBlog.edges.forEach(edge => {
createPage({
path: edge.node.slug,
component: blogPost,
context: {
slug: edge.node.slug,
},
})
})
return
})
)
})
}
exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
const { createNodeField } = boundActionCreators
}
Это мой файл gatsby-node.js.
Терминал дает:
TypeError: невозможно прочитать свойство allContentfulBlog, равное undefined.
На Contentful.com тип контента называется Блог.
Я прикрепил снимок экрана терминала сюда.
Есть какие-нибудь намеки?