{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/10941","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/10941/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/10941/comments","events_url":"https://api.github.com/repos/facebook/react/issues/10941/events","html_url":"https://github.com/facebook/react/pull/10941","id":261475807,"number":10941,"title":"Gh pages redirects","user":{"login":"bvaughn","id":29597,"avatar_url":"https://avatars0.githubusercontent.com/u/29597?v=4","gravatar_id":"","url":"https://api.github.com/users/bvaughn","html_url":"https://github.com/bvaughn","followers_url":"https://api.github.com/users/bvaughn/followers","following_url":"https://api.github.com/users/bvaughn/following{/other_user}","gists_url":"https://api.github.com/users/bvaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/bvaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvaughn/subscriptions","organizations_url":"https://api.github.com/users/bvaughn/orgs","repos_url":"https://api.github.com/users/bvaughn/repos","events_url":"https://api.github.com/users/bvaughn/events{/privacy}","received_events_url":"https://api.github.com/users/bvaughn/received_events","type":"User","site_admin":false},"labels":[{"id":196858374,"url":"https://api.github.com/repos/facebook/react/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-09-28T22:06:50Z","updated_at":"2017-09-28T22:21:53Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/facebook/react/pulls/10941","html_url":"https://github.com/facebook/react/pull/10941","diff_url":"https://github.com/facebook/react/pull/10941.diff","patch_url":"https://github.com/facebook/react/pull/10941.patch"},"body":"Proposed alternative to #10856; continuation of #10936.\r\n\r\nI updated the Gatsby site `gatsby-node.js` script to log each page and redirect path it generates. (This should be the entire list of unique URLs for the new/old site.) Then I ran the following script:\r\n\r\n```js\r\nconst {existsSync, mkdirSync, writeFileSync} = require('fs');\r\nconst {join} = require('path');\r\n\r\nconst urls = `...`; // From gatsby-node.js\r\n\r\nconst createPage = path => `\r\n<html>\r\n  <head>\r\n    <meta http-equiv=\"refresh\" content=\"0; url=https://reactjs.org/${path}\">\r\n    <link rel=\"canonical\" href=\"https://reactjs.org/${path}\">\r\n  </head>\r\n  <body>\r\n    Redirecting to <a href=\"https://reactjs.org/${path}\">https://reactjs.org/${path}</a>...\r\n  </body>\r\n</html>\r\n`;\r\n\r\nurls.trim().split('\\n').forEach(path => {\r\n  let bound = 0;\r\n  while (true) {\r\n    const index = path.indexOf('/', bound);\r\n\r\n    if (index >= 0) {\r\n      let subpath = path.substr(0, index);\r\n      subpath = join(__dirname, subpath);\r\n\r\n      if (!existsSync(subpath)) {\r\n        mkdirSync(subpath);\r\n      }\r\n\r\n      bound = index + 1;\r\n    } else {\r\n      break;\r\n    }\r\n  }\r\n\r\n  writeFileSync(\r\n    join(__dirname, path),\r\n    createPage(path)\r\n  );\r\n});\r\n```\r\n\r\nSpot checking a few of the generated pages seems to work. I'll push the results momentarily.\r\n\r\ncategory | type\r\n:---|:---\r\nroot url | https://bvaughn.github.io/react/\r\nno .html | https://bvaughn.github.io/react/docs/installation\r\nnested url | https://bvaughn.github.io/react/blog/2017/05/18/whats-new-in-create-react-app.html\r\nnon-markdown page | https://bvaughn.github.io/react/blog/all.html\r\nquery params | https://bvaughn.github.io/react/docs/error-decoder.html?invariant=109&args[]=Foo"},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/332980059","html_url":"https://github.com/facebook/react/pull/10941#issuecomment-332980059","issue_url":"https://api.github.com/repos/facebook/react/issues/10941","id":332980059,"user":{"login":"gaearon","id":810438,"avatar_url":"https://avatars0.githubusercontent.com/u/810438?v=4","gravatar_id":"","url":"https://api.github.com/users/gaearon","html_url":"https://github.com/gaearon","followers_url":"https://api.github.com/users/gaearon/followers","following_url":"https://api.github.com/users/gaearon/following{/other_user}","gists_url":"https://api.github.com/users/gaearon/gists{/gist_id}","starred_url":"https://api.github.com/users/gaearon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaearon/subscriptions","organizations_url":"https://api.github.com/users/gaearon/orgs","repos_url":"https://api.github.com/users/gaearon/repos","events_url":"https://api.github.com/users/gaearon/events{/privacy}","received_events_url":"https://api.github.com/users/gaearon/received_events","type":"User","site_admin":false},"created_at":"2017-09-28T22:21:53Z","updated_at":"2017-09-28T22:21:53Z","author_association":"MEMBER","body":"Ah I see. I was thinking we could have a script on each page that takes control first and thus provides better experience for the browsers (as opposed to the crawlers). \r\n\r\nIn particular I'd love if we can keep fragments working. We have many links to particular sections (e.g. \"Use the production build\") of pages and I'd prefer if they keep working. Although now that I think of it I remember Gatsby has a different fragment slug generation behavior."}}
{"actor":{"display_login":"gaearon"}}