From d4dc222accacdd7a2ccc7aae11a0e9b11b2942b0 Mon Sep 17 00:00:00 2001 From: Clinton Date: Tue, 4 May 2021 09:12:15 -0700 Subject: [PATCH 1/4] chore: add theme config option to force trailing slashes --- gatsby-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gatsby-config.js b/gatsby-config.js index fc5aeecb0..43d6b7931 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -16,6 +16,7 @@ module.exports = { { resolve: '@newrelic/gatsby-theme-newrelic', options: { + forceTrailingSlashes: true, layout: { contentPadding: '2rem', maxWidth: '1700px', From 6b02b71a07a535c2e17118968fa59e3701659f67 Mon Sep 17 00:00:00 2001 From: Clinton Date: Tue, 4 May 2021 09:36:29 -0700 Subject: [PATCH 2/4] chore: manually aadd trailing slash to paths when creating pages --- gatsby-node.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index aed610cd4..eff903b53 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -82,7 +82,9 @@ exports.createPages = async ({ actions, graphql, reporter }) => { } createPage({ - path: frontmatter.path || slug, + path: frontmatter.path + ? path.join(frontmatter.path, '/') + : path.join(slug, '/'), component: path.resolve(`src/templates/${frontmatter.template}.js`), context: { slug, @@ -101,7 +103,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => { } = node; createPage({ - path: slug, + path: path.join(slug, '/'), component: path.resolve('./src/templates/ComponentReferenceTemplate.js'), context: { slug, @@ -115,7 +117,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => { } = node; createPage({ - path: slug, + path: path.join(slug, '/'), component: path.resolve('./src/templates/ApiReferenceTemplate.js'), context: { slug, From adf49874d45593d308b4c9605d33456b682677a4 Mon Sep 17 00:00:00 2001 From: Clinton Date: Tue, 4 May 2021 09:48:56 -0700 Subject: [PATCH 3/4] refactor: change field that GuideTemplate uses to find given node at path --- src/templates/GuideTemplate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/GuideTemplate.js b/src/templates/GuideTemplate.js index eaf853c34..166d455fe 100644 --- a/src/templates/GuideTemplate.js +++ b/src/templates/GuideTemplate.js @@ -75,8 +75,8 @@ GuideTemplate.propTypes = { }; export const pageQuery = graphql` - query($path: String!) { - mdx(frontmatter: { path: { eq: $path } }) { + query($slug: String!) { + mdx(fields: { slug: { eq: $slug } }) { body frontmatter { duration From 614ba41a3d133b3728ef299dcf26e574c7741c21 Mon Sep 17 00:00:00 2001 From: Clinton Date: Tue, 4 May 2021 09:52:07 -0700 Subject: [PATCH 4/4] chore: update OverviewTemplate to also use different field to match node path --- src/templates/OverviewTemplate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/OverviewTemplate.js b/src/templates/OverviewTemplate.js index af8fef755..ff142a8c8 100644 --- a/src/templates/OverviewTemplate.js +++ b/src/templates/OverviewTemplate.js @@ -60,8 +60,8 @@ OverviewTemplate.propTypes = { }; export const pageQuery = graphql` - query($path: String!, $guidesFilter: String!) { - mdx(frontmatter: { path: { eq: $path } }) { + query($slug: String!, $guidesFilter: String!) { + mdx(fields: { slug: { eq: $slug } }) { body frontmatter { path