Browse Source

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

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

10
gatsby/createPages.js

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

Loading…
Cancel
Save