Skip to content

Commit

Permalink
chore: Add error when path does not match slug
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Nov 28, 2021
1 parent 0c2f080 commit 3db0313
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
});
}

if (frontmatter.path !== slug) {
const newPath = path.join(
'src/markdown-pages',
fileRelativePath.endsWith('index.mdx')
? path.join(frontmatter.path, 'index.mdx')
: `${frontmatter.path}.mdx`
);

reporter.error(
`
File path does not match frontmatter path:
mkdir -p ${path.dirname(newPath)}
mv ${fileRelativePath} ${newPath}
`.trim()
);
}

createPage({
path: frontmatter.path
? path.join(frontmatter.path, '/')
Expand Down

0 comments on commit 3db0313

Please sign in to comment.