Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gatsbyjs/store.gatsbyjs.org
Browse files Browse the repository at this point in the history
  • Loading branch information
jlengstorf committed Jan 11, 2019
2 parents c748dda + 9f3ecdc commit 9b48774
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require('path');

exports.createPages = async ({ graphql, actions: { createPage } }) => {
exports.createPages = async ({
graphql,
actions: { createPage, createRedirect }
}) => {
const pages = await graphql(`
{
allShopifyProduct {
Expand All @@ -24,6 +27,35 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
}
});
});

// Redirects for old product slugs.
[
{
oldSlug: 'purple-logo-tee-w-natural-process-print',
newSlug: 'vintage-purple-tee'
},
{
oldSlug: 'copy-of-gatsby-full-zip-sweatshirt-horizontal-logo',
newSlug: 'all-purple-everything-hoodie'
},
{
oldSlug: 'gatsby-full-zip-sweatshirt',
newSlug: 'all-purple-everything-hoodie-vertical'
},
{ oldSlug: 'black-socks', newSlug: 'space-socks' },
{ oldSlug: 'dark-deploy-t-shirt', newSlug: 'dark-deploy-tee' },
{ oldSlug: 'gatsby-trucker-hat', newSlug: 'monogram-trucker-hat' },
{ oldSlug: 'gatsby-water-bottle', newSlug: '12oz-travel-mug' },
{ oldSlug: 'purple-gatsby-hat', newSlug: 'blazig-purple-hat' }
].map(({ oldSlug, newSlug }) => {
const config = {
toPath: `/product/${newSlug}`,
isPermanent: true,
redirectInBrowser: true
};
createRedirect({ fromPath: `/product/${oldSlug}`, ...config });
createRedirect({ fromPath: `/product/${oldSlug}/`, ...config });
});
};

exports.onCreatePage = async ({ page, actions: { createPage } }) => {
Expand Down

0 comments on commit 9b48774

Please sign in to comment.