我有一个 Gatsby Prismic 博客,其中包含两种自定义内容类型 - 指南和评论。
我希望 URL 结构为 www.mysite.com/guide_url/review_url。
到目前为止我所做的:
我已将 Prismic 中的内容关系字段添加到父自定义类型指南并将子项(评论)链接到它。
在我的 gatsby-node.js 文件中,代码如下所示:
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators;
return new Promise((resolve, reject) => {
graphql(`
{
allPrismicGuide {
edges {
node {
id
uid
}
}
}
allPrismicReview {
edges {
node {
id
uid
}
}
}
`).then(result => {
const categoriesSet = new Set();
result.data.allPrismicGuide.edges.forEach(({ node }) => {
createPage({
path: node.uid,
component: path.resolve(`./src/templates/GuideTemplate.js`),
context: {
// Data passed to context is available in page queries as GraphQL variables.
slug: node.uid
}
});
});
result.data.allPrismicReview.edges.forEach(({ node }) => {
createPage({
path: node.uid,
component: path.resolve(`./src/templates/ReviewTemplate.js`),
context: {
// Data passed to context is available in page queries as GraphQL variables.
slug: node.uid,
tags: node.tags
}
});
});
我对盖茨比和棱镜很陌生。
我很想得到一些反馈(有用的链接)和建议!