From 9586bdfed6386afb30587af89c96c2847e37bfe1 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Sun, 28 Nov 2021 00:28:34 -0800 Subject: [PATCH] fix: Add deprecation warning for path property when creating pages --- gatsby-node.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index d9216b65b..66a6b744f 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -96,19 +96,24 @@ exports.createPages = async ({ actions, graphql, reporter }) => { }); } - if (frontmatter.path !== slug) { - const newPath = path.join( + if (frontmatter.path) { + const recommendedPath = path.join( 'src/markdown-pages', fileRelativePath.endsWith('index.mdx') ? path.join(frontmatter.path, 'index.mdx') : `${frontmatter.path}.mdx` ); - reporter.error( + const recommendation = + recommendedPath === fileRelativePath + ? "Please remove the 'path' property." + : `To render this page at '${frontmatter.path}', please move this file to: '${recommendedPath}'.`; + + reporter.panicOnBuild( ` -File path does not match frontmatter path: - mkdir -p ${path.dirname(newPath)} - mv ${fileRelativePath} ${newPath} +${fileRelativePath} + +The 'path' property on frontmatter is deprecated and has no effect. URLs are now generated using the path of the file. ${recommendation} `.trim() ); }