我正在使用 Drupal CMS 作为后端创建一个 Gatsby 网站。我在 Drupal 中有登陆页面内容类型,它提供主页和关于我们的页面。现在Drupal主页路径是/home。但 Gatsby 有主页 URL '/'。从 Drupal 提取数据后,Gatsby 认为 /home 是单独的页面而不是索引页面。
我尝试在 Gatsby 节点 js 文件上的 CreatePage API 中设置路径。但没有成功。
她是我的发现,
result.data.allNodeLanding.edges.forEach(({ node }) => {
const slug = node.fields.slug;
if (node.fields.slug === '/home/') {
node.fields.slug = '/'
}
actions.createPage({
path: node.fields.slug,
component: tpl,
context: {
slug: slug
}
});
});