Skip to content

Commit

Permalink
Fix redirects
Browse files Browse the repository at this point in the history
- Ensure redirects don't include current version
- Change "next" redirect to a permanent proxy rewrite
  • Loading branch information
kylegach committed Nov 9, 2021
1 parent 4d2174e commit 79ced07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,14 @@ function generateVersionsFile() {
function updateRedirectsFile() {
const originalContents = fs.readFileSync('./static/_redirects');
const newContents = [...versions.stable, ...versions.preRelease]
.reduce((acc, { string, label }) => {
if (label !== 'latest') {
.reduce((acc, { string }) => {
if (string !== latestVersionString) {
acc.push(`/docs/${string}/* ${getReleaseBranchUrl(string)}/docs/${string}/:splat 200`);
}
return acc;
}, [])
.concat([
`/docs/next/* ${getReleaseBranchUrl(nextVersionString)}/docs/${nextVersionString}/:splat 302`,
`/docs/next/* ${getReleaseBranchUrl(nextVersionString)}/docs/${nextVersionString}/:splat 200`,
])
.join('\n');
fs.writeFileSync('./public/_redirects', `${originalContents}\n\n${newContents}`);
Expand Down

0 comments on commit 79ced07

Please sign in to comment.