Browse Source

fix: redirect slugs with and without trailing slashes (#1209)

fixes #1208
main
Jason Lengstorf 7 years ago
committed by Dan Abramov
parent
commit
6d48f5661a
  1. 4
      gatsby/createPages.js

4
gatsby/createPages.js

@ -147,9 +147,11 @@ module.exports = async ({graphql, actions}) => {
const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node; const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node;
// Blog landing page should always show the most recent blog entry. // Blog landing page should always show the most recent blog entry.
['/blog/', '/blog'].map(slug => {
createRedirect({ createRedirect({
fromPath: '/blog/', fromPath: slug,
redirectInBrowser: true, redirectInBrowser: true,
toPath: newestBlogNode.fields.slug, toPath: newestBlogNode.fields.slug,
}); });
});
}; };

Loading…
Cancel
Save