Skip to content

Commit

Permalink
feat(www): Move redirects in www/gatsby-node to a yaml file (#20656)
Browse files Browse the repository at this point in the history
* move redirects to a yaml file

* missed one
  • Loading branch information
tesseralis authored and LekoArts committed Jan 17, 2020
1 parent 0b3684e commit 0e1b717
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 376 deletions.
379 changes: 3 additions & 376 deletions www/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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({ isPermanent: true, ...redirect })
})

Object.entries(startersRedirects).forEach(([fromSlug, toSlug]) => {
Expand Down Expand Up @@ -863,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

Expand Down
Loading

0 comments on commit 0e1b717

Please sign in to comment.