Merge pull request #37 from tchaffee/fix/stub-superblock-index-pages

Add superBlock intro pages
This commit is contained in:
Stuart Taylor
2018-05-18 11:59:12 +01:00
committed by Mrugesh Mohapatra
parent 571209809c
commit 04a6a2026c
9 changed files with 125 additions and 10 deletions

View File

@ -21,7 +21,14 @@ exports.onCreateNode = function onCreateNode({ node, boundActionCreators }) {
if (node.internal.type === 'MarkdownRemark') {
const { frontmatter: { block, superBlock } } = node;
const slug = `/${dasherize(superBlock)}/${dasherize(block)}`;
let slug = `/${dasherize(superBlock)}`;
// Without this condition the slug for superblocks ends up as something like
// "/apis-and-microservice/undefined" and what we want instead is just
// "/apis-and-microservice"
if (typeof block !== 'undefined') {
slug = slug + `/${dasherize(block)}`;
}
createNodeField({ node, name: 'slug', value: slug });
}