Skip to content

Commit

Permalink
Merge pull request #1299 from newrelic/clinton/trailing-slashes
Browse files Browse the repository at this point in the history
Force trailing slashes on page paths
  • Loading branch information
roadlittledawn authored May 4, 2021
2 parents 19fb479 + 614ba41 commit 37a35d1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
{
resolve: '@newrelic/gatsby-theme-newrelic',
options: {
forceTrailingSlashes: true,
layout: {
contentPadding: '2rem',
maxWidth: '1700px',
Expand Down
8 changes: 5 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/templates/GuideTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/templates/OverviewTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 37a35d1

Please sign in to comment.