【发布时间】:2020-10-23 09:35:25
【问题描述】:
昨天和几个月来,当通过 Contentful 添加博客文章触发 Netlify 上的构建钩子时,一切正常。今天一篇新的博客文章通过 Netlify 添加和构建钩子不起作用。在本地运行 gatsby develop 或 gatsby build 时,一切正常,新的博文就在那里。
这是 Netlify 上的错误:错误“gatsby-node.js”在运行 createPages 生命周期时抛出错误: 7:19:16 PM:Reducers 可能不会调度操作:
- 已尝试通过 Netlify 进行“清除缓存并部署站点”按钮
- 已尝试 gatsby clean、npm install 并通过 GitHub 推送触发部署
不确定如何确认缓存已清除以及接下来要尝试什么。有什么想法吗?
创建页面:
const Promise = require('bluebird');
const path = require('path');
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions;
const typeDefs = `
type ContentfulHeroBanner implements Node {
headerLeft: String
headerCenter: String
headerRight: String
}
`;
createTypes(typeDefs);
};
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise((resolve, reject) => {
const blogPost = path.resolve('./src/templates/blog-post.js');
resolve(
graphql(
`
{
allContentfulBlogPost {
edges {
node {
title
slug
}
}
}
}
`
).then(result => {
if (result.errors) {
console.log(result.errors);
reject(result.errors);
}
const posts = result.data.allContentfulBlogPost.edges;
posts.forEach((post, index) => {
createPage({
path: `/blog/${post.node.slug}/`,
component: blogPost,
context: {
slug: post.node.slug,
},
});
});
})
);
});
};
【问题讨论】:
-
不知道你的项目代码是不可能的。可以把
createPages的内容发到gatsby-node.js吗? -
@ehrencrona,将此文件添加到问题中。虽然它已经几个月没有修改了。
-
好的,在这里找到了一些有趣的信息:community.netlify.com/t/…。如果我不使用它,看起来我可以删除我的 yarn.lock 文件。
标签: gatsby netlify contentful