From b65be175b6555ffc517a4fa039ea484e24c22c4f Mon Sep 17 00:00:00 2001 From: Nat Alison Date: Thu, 16 Jan 2020 19:15:39 -0800 Subject: [PATCH 1/2] move redirects to a yaml file --- www/gatsby-node.js | 372 +-------------------------------------------- www/redirects.yaml | 134 ++++++++++++++++ 2 files changed, 137 insertions(+), 369 deletions(-) create mode 100644 www/redirects.yaml diff --git a/www/gatsby-node.js b/www/gatsby-node.js index 603c69b7642e9..810dbac3052f9 100644 --- a/www/gatsby-node.js +++ b/www/gatsby-node.js @@ -24,6 +24,7 @@ const tutorialLinksData = yaml.load( const contributingLinksData = yaml.load( fs.readFileSync(`./src/data/sidebars/contributing-links.yaml`) ) +const redirects = yaml.load(fs.readFileSync(`./redirects.yaml`)) let ecosystemFeaturedItems @@ -60,375 +61,8 @@ const slugToAnchor = slug => exports.createPages = ({ graphql, actions, reporter }) => { const { createPage, createRedirect } = actions - createRedirect({ - fromPath: `/docs/themes/api-reference`, - toPath: `/docs/theme-api/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/component-css/`, // Merged Component CSS and CSS Modules - toPath: `/docs/css-modules/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/blog/2018-10-25-unstructured-data/`, - toPath: `/blog/2018-10-25-using-gatsby-without-graphql/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/using-unstructured-data/`, - toPath: `/docs/using-gatsby-without-graphql/`, - isPermanent: true, - }) - - // Random redirects - createRedirect({ - fromPath: `/blog/2018-02-26-documentation-project/`, // Tweeted this link out then switched it - toPath: `/blog/2018-02-28-documentation-project/`, - isPermanent: true, - }) - - // Redirects for new top-level Contributing section - createRedirect({ - fromPath: `/community/`, // Moved "Community" page from /community to /contributing/community - toPath: `/contributing/community/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/community/`, // Moved "Community" page from /docs/community to /contributing/community - toPath: `/contributing/community/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/deploying-to-now/`, - toPath: `/docs/deploying-to-zeit-now/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/pair-programming/`, - toPath: `/contributing/pair-programming/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/how-to-create-an-issue/`, - toPath: `/contributing/how-to-create-an-issue/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/how-to-label-an-issue/`, - toPath: `/contributing/how-to-label-an-issue/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/contributor-swag/`, - toPath: `/contributing/contributor-swag/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/how-to-run-a-gatsby-workshop/`, - toPath: `/contributing/how-to-run-a-gatsby-workshop/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/how-to-pitch-gatsby/`, - toPath: `/contributing/how-to-pitch-gatsby/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/code-of-conduct/`, - toPath: `/contributing/code-of-conduct/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/gatsby-style-guide/`, - toPath: `/contributing/gatsby-style-guide/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/how-to-contribute/`, - toPath: `/contributing/how-to-contribute/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/templates/`, - toPath: `/contributing/docs-templates/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/site-showcase-submissions/`, - toPath: `/contributing/site-showcase-submissions/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/submit-to-creator-showcase/`, - toPath: `/contributing/submit-to-creator-showcase/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/submit-to-starter-library/`, - toPath: `/contributing/submit-to-starter-library/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/submit-to-plugin-library/`, - toPath: `/contributing/submit-to-plugin-library/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/rfc-process/`, - toPath: `/contributing/rfc-process/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/packages/`, // Moved "Plugins" page from /packages to /plugins - toPath: `/plugins/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/netlify-cms/`, - toPath: `/docs/sourcing-from-netlify-cms/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/sourcing-from-saas-services/`, - toPath: `/docs/sourcing-from-hosted-services/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/starter-showcase/`, // Moved "Starter Showcase" index page from /starter-showcase to /starters - toPath: `/starters/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/gatsby-starters/`, // Main Gatsby starters page is the starter library - toPath: `/starters/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/adding-third-party-services/`, - toPath: `/docs/adding-website-functionality/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/bound-action-creators/`, - toPath: `/docs/actions/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/bound-action-creators`, - toPath: `/docs/actions`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/adding-images-fonts-files`, - toPath: `/docs/importing-assets-into-files`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/blog/2019-10-03-gatsby-perf`, - toPath: `/blog/2018-10-03-gatsby-perf`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/add-a-service-worker`, - toPath: `/docs/add-offline-support-with-a-service-worker`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/add-offline-support`, - toPath: `/docs/add-offline-support-with-a-service-worker`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/create-source-plugin/`, - toPath: `/docs/creating-a-source-plugin/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/create-transformer-plugin/`, - toPath: `/docs/creating-a-transformer-plugin/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/plugin-authoring/`, - toPath: `/docs/how-plugins-work/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/source-plugin-tutorial/`, - toPath: `/docs/pixabay-source-plugin-tutorial/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/how-plugins-work/`, - toPath: `/docs/plugins/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/blog/2018-2-16-how-to-build-a-website-with-react/`, - toPath: `/blog/2019-01-16-how-to-build-a-website-with-react/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/advanced-tutorials/`, - toPath: `/tutorial/additional-tutorials/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/tutorial/advanced-tutorials/`, - toPath: `/tutorial/additional-tutorials/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/authentication-tutorial/`, - toPath: `/tutorial/authentication-tutorial/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/ecommerce-tutorial/`, - toPath: `/tutorial/ecommerce-tutorial/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/image-tutorial/`, - toPath: `/tutorial/wordpress-image-tutorial/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/tutorial/image-tutorial/`, - toPath: `/tutorial/wordpress-image-tutorial/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/wordpress-source-plugin-tutorial/`, - toPath: `/tutorial/wordpress-source-plugin-tutorial/`, - isPermanent: true, - }) - createRedirect({ - fromPath: `/docs/writing-documentation-with-docz/`, - toPath: `/tutorial/writing-documentation-with-docz/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/behind-the-scenes/`, - toPath: `/docs/gatsby-internals/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/behind-the-scenes-terminology/`, - toPath: `/docs/gatsby-internals-terminology/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/themes/getting-started`, - toPath: `/docs/themes/using-a-gatsby-theme`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/themes/introduction`, - toPath: `/docs/themes/what-are-gatsby-themes`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/hosting-on-netlify/`, - toPath: `/docs/deploying-to-netlify/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/querying-with-graphql/`, - toPath: `/docs/graphql-concepts/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/introducing-graphiql/`, - toPath: `/docs/running-queries-with-graphiql/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/life-and-times-of-a-gatsby-build/`, - toPath: `/docs/overview-of-the-gatsby-build-process/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/awesome-gatsby/`, - toPath: `/docs/awesome-gatsby-resources/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/sourcing-from-kentico-cloud/`, - toPath: `/docs/sourcing-from-kentico-kontent/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/building-apps-with-gatsby/`, - toPath: `/docs/adding-app-and-website-functionality/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/adding-website-functionality/`, - toPath: `/docs/adding-app-and-website-functionality/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/using-fragments/`, - toPath: `/docs/using-graphql-fragments/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/client-data-fetching/`, - toPath: `/docs/data-fetching/`, - isPermanent: true, - }) - - createRedirect({ - fromPath: `/docs/centralizing-your-sites-navigation/`, - toPath: `/docs/creating-dynamic-navigation/`, - isPermanent: true, - }) - - /* This redirects from a now removed stub that - showed up in the first page of Google results. - Can be removed if SEO is no longer impacted. */ - - createRedirect({ - fromPath: `/docs/rendering-sidebar-navigation-dynamically/`, - toPath: `/docs/creating-dynamic-navigation/`, - isPermanent: true, + redirects.forEach(redirect => { + createRedirect({ ...redirect, isPermanent: true }) }) Object.entries(startersRedirects).forEach(([fromSlug, toSlug]) => { diff --git a/www/redirects.yaml b/www/redirects.yaml new file mode 100644 index 0000000000000..14da10efa64dc --- /dev/null +++ b/www/redirects.yaml @@ -0,0 +1,134 @@ +- fromPath: /docs/themes/api-reference + toPath: /docs/theme-api/ +- fromPath: /docs/component-css/ # Merged Component CSS and CSS Modules + toPath: /docs/css-modules/ +- fromPath: /blog/2018-10-25-unstructured-data/ + toPath: /blog/2018-10-25-using-gatsby-without-graphql/ +- fromPath: /docs/using-unstructured-data/ + toPath: /docs/using-gatsby-without-graphql/ + # Random redirects +- fromPath: /blog/2018-02-26-documentation-project/ # Tweeted this link out then switched it + toPath: /blog/2018-02-28-documentation-project/ + # Redirects for new top-level Contributing section +- fromPath: /community/ # Moved "Community" page from /community to /contributing/community + toPath: /contributing/community/ +- fromPath: /docs/community/ # Moved "Community" page from /docs/community to /contributing/community + toPath: /contributing/community/ +- fromPath: /docs/deploying-to-now/ + toPath: /docs/deploying-to-zeit-now/ +- fromPath: /docs/pair-programming/ + toPath: /contributing/pair-programming/ +- fromPath: /docs/how-to-create-an-issue/ + toPath: /contributing/how-to-create-an-issue/ +- fromPath: /docs/how-to-label-an-issue/ + toPath: /contributing/how-to-label-an-issue/ +- fromPath: /docs/contributor-swag/ + toPath: /contributing/contributor-swag/ +- fromPath: /docs/how-to-run-a-gatsby-workshop/ + toPath: /contributing/how-to-run-a-gatsby-workshop/ +- fromPath: /docs/how-to-pitch-gatsby/ + toPath: /contributing/how-to-pitch-gatsby/ +- fromPath: /docs/code-of-conduct/ + toPath: /contributing/code-of-conduct/ +- fromPath: /docs/gatsby-style-guide/ + toPath: /contributing/gatsby-style-guide/ +- fromPath: /docs/how-to-contribute/ + toPath: /contributing/how-to-contribute/ +- fromPath: /docs/templates/ + toPath: /contributing/docs-templates/ +- fromPath: /docs/site-showcase-submissions/ + toPath: /contributing/site-showcase-submissions/ +- fromPath: /docs/submit-to-creator-showcase/ + toPath: /contributing/submit-to-creator-showcase/ +- fromPath: /docs/submit-to-starter-library/ + toPath: /contributing/submit-to-starter-library/ +- fromPath: /docs/submit-to-plugin-library/ + toPath: /contributing/submit-to-plugin-library/ +- fromPath: /docs/rfc-process/ + toPath: /contributing/rfc-process/ +- fromPath: /packages/ # Moved "Plugins" page from /packages to /plugins + toPath: /plugins/ +- fromPath: /docs/netlify-cms/ + toPath: /docs/sourcing-from-netlify-cms/ +- fromPath: /docs/sourcing-from-saas-services/ + toPath: /docs/sourcing-from-hosted-services/ +- fromPath: /starter-showcase/ # Moved "Starter Showcase" index page from /starter-showcase to /starters + toPath: /starters/ +- fromPath: /docs/gatsby-starters/ # Main Gatsby starters page is the starter library + toPath: /starters/ +- fromPath: /docs/adding-third-party-services/ + toPath: /docs/adding-website-functionality/ +- fromPath: /docs/bound-action-creators/ + toPath: /docs/actions/ +- fromPath: /docs/bound-action-creators + toPath: /docs/actions +- fromPath: /docs/adding-images-fonts-files + toPath: /docs/importing-assets-into-files +- fromPath: /blog/2019-10-03-gatsby-perf + toPath: /blog/2018-10-03-gatsby-perf +- fromPath: /docs/add-a-service-worker + toPath: /docs/add-offline-support-with-a-service-worker +- fromPath: /docs/add-offline-support + toPath: /docs/add-offline-support-with-a-service-worker +- fromPath: /docs/create-source-plugin/ + toPath: /docs/creating-a-source-plugin/ +- fromPath: /docs/create-transformer-plugin/ + toPath: /docs/creating-a-transformer-plugin/ +- fromPath: /docs/plugin-authoring/ + toPath: /docs/how-plugins-work/ +- fromPath: /docs/source-plugin-tutorial/ + toPath: /docs/pixabay-source-plugin-tutorial/ +- fromPath: /docs/how-plugins-work/ + toPath: /docs/plugins/ +- fromPath: /blog/2018-2-16-how-to-build-a-website-with-react/ + toPath: /blog/2019-01-16-how-to-build-a-website-with-react/ +- fromPath: /docs/advanced-tutorials/ + toPath: /tutorial/additional-tutorials/ +- fromPath: /tutorial/advanced-tutorials/ + toPath: /tutorial/additional-tutorials/ +- fromPath: /docs/authentication-tutorial/ + toPath: /tutorial/authentication-tutorial/ +- fromPath: /docs/ecommerce-tutorial/ + toPath: /tutorial/ecommerce-tutorial/ +- fromPath: /docs/image-tutorial/ + toPath: /tutorial/wordpress-image-tutorial/ +- fromPath: /tutorial/image-tutorial/ + toPath: /tutorial/wordpress-image-tutorial/ +- fromPath: /docs/wordpress-source-plugin-tutorial/ + toPath: /tutorial/wordpress-source-plugin-tutorial/ +- fromPath: /docs/writing-documentation-with-docz/ + toPath: /tutorial/writing-documentation-with-docz/ +- fromPath: /docs/behind-the-scenes/ + toPath: /docs/gatsby-internals/ +- fromPath: /docs/behind-the-scenes-terminology/ + toPath: /docs/gatsby-internals-terminology/ +- fromPath: /docs/themes/getting-started + toPath: /docs/themes/using-a-gatsby-theme +- fromPath: /docs/themes/introduction + toPath: /docs/themes/what-are-gatsby-themes +- fromPath: /docs/hosting-on-netlify/ + toPath: /docs/deploying-to-netlify/ +- fromPath: /docs/querying-with-graphql/ + toPath: /docs/graphql-concepts/ +- fromPath: /docs/introducing-graphiql/ + toPath: /docs/running-queries-with-graphiql/ +- fromPath: /docs/life-and-times-of-a-gatsby-build/ + toPath: /docs/overview-of-the-gatsby-build-process/ +- fromPath: /docs/awesome-gatsby/ + toPath: /docs/awesome-gatsby-resources/ +- fromPath: /docs/sourcing-from-kentico-cloud/ + toPath: /docs/sourcing-from-kentico-kontent/ +- fromPath: /docs/building-apps-with-gatsby/ + toPath: /docs/adding-app-and-website-functionality/ +- fromPath: /docs/adding-website-functionality/ + toPath: /docs/adding-app-and-website-functionality/ +- fromPath: /docs/using-fragments/ + toPath: /docs/using-graphql-fragments/ +- fromPath: /docs/client-data-fetching/ + toPath: /docs/data-fetching/ +- fromPath: /docs/centralizing-your-sites-navigation/ + toPath: /docs/creating-dynamic-navigation/ + # This redirects from a now removed stub that showed up in the first page of Google results. + # Can be removed if SEO is no longer impacted. +- fromPath: /docs/rendering-sidebar-navigation-dynamically/ + toPath: /docs/creating-dynamic-navigation/ From 70975dad287a0cba836af78daf32a1bd1e6d93e4 Mon Sep 17 00:00:00 2001 From: Nat Alison Date: Thu, 16 Jan 2020 19:57:06 -0800 Subject: [PATCH 2/2] missed one --- www/gatsby-node.js | 9 +-------- www/redirects.yaml | 3 +++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/www/gatsby-node.js b/www/gatsby-node.js index 810dbac3052f9..8620c31d4e967 100644 --- a/www/gatsby-node.js +++ b/www/gatsby-node.js @@ -62,7 +62,7 @@ exports.createPages = ({ graphql, actions, reporter }) => { const { createPage, createRedirect } = actions redirects.forEach(redirect => { - createRedirect({ ...redirect, isPermanent: true }) + createRedirect({ isPermanent: true, ...redirect }) }) Object.entries(startersRedirects).forEach(([fromSlug, toSlug]) => { @@ -497,13 +497,6 @@ exports.createPages = ({ graphql, actions, reporter }) => { }) } - // redirecting cypress-gatsby => gatsby-cypress - createRedirect({ - fromPath: `/packages/cypress-gatsby/`, - toPath: `/packages/gatsby-cypress/`, - isPermanent: true, - }) - // Read featured starters and plugins for Ecosystem ecosystemFeaturedItems = result.data.allEcosystemYaml.edges[0].node diff --git a/www/redirects.yaml b/www/redirects.yaml index 14da10efa64dc..d62b9b07fe032 100644 --- a/www/redirects.yaml +++ b/www/redirects.yaml @@ -132,3 +132,6 @@ # Can be removed if SEO is no longer impacted. - fromPath: /docs/rendering-sidebar-navigation-dynamically/ toPath: /docs/creating-dynamic-navigation/ + # redirecting cypress-gatsby => gatsby-cypress +- fromPath: /packages/cypress-gatsby/ + toPath: /packages/gatsby-cypress/