Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate v1 -> v2 redirects for all production pages #611

Merged
merged 1 commit into from
Sep 23, 2020
Merged

Generate v1 -> v2 redirects for all production pages #611

merged 1 commit into from
Sep 23, 2020

Conversation

jasonbcox
Copy link
Collaborator

With v1 pages on their way out, we need to redirect v1 pages to v2 pages. This way, links to the old v1 routes will still work, but see the new experience.

This patch adds the necessary machinery to introduce those redirects and is testable as a stand-alone change. However, in order to push this to production, the v1 configs in nginx need to be cleaned up first. That patch will soon follow.

Test plan:

npm run develop

Navigate around. Pages still work as expected and v1 links such as localhost:8000/start-here.html redirect to their appropriate v2 counterparts.

mv src/pages/accept-bitcoin-cash.js src/jekyll-migration
GATSBY_APP_ENV=prod npm run develop

In addition to the above tested behavior, pages in the jekyll migration directory still redirect in the v2 -> v1 direction as expected.

@@ -92,7 +100,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
// In production, we redirect in-development v2 pages to v1 equivalent routes.
// In non-prod environments, we create all pages and do not redirect.
if (process.env.GATSBY_APP_ENV == "prod") {
await createRedirectForEachLocale(createRedirect, page)
await createRedirectForEachLocale(createRedirect, page, fromHtmlPage = false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this creates a global variable and by no mean is a named argument

@@ -35,15 +35,23 @@ const createPageForEachLocale = async (createPage, page) => {
)
}

const createRedirectForEachLocale = async (createRedirect, page) => {
const createRedirectForEachLocale = async (createRedirect, page, fromHtmlPage = true) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean in API = beark.

Just pass a customized version of createRedirect that do the switcharoo and rename a few things so that they make sense.

@deadalnix deadalnix merged commit 754c2a1 into bitcoincashorg:master Sep 23, 2020
EyeOfPython pushed a commit to EyeOfPython/bitcoincash.org that referenced this pull request Nov 17, 2020
@shadi19838410 shadi19838410 linked an issue Mar 23, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants