Skip to content

Commit e06b3ec

Browse files
authored
restore legacy 301 redirects (graphql#1503)
1 parent b52ece7 commit e06b3ec

File tree

3 files changed

+76
-25
lines changed

3 files changed

+76
-25
lines changed

gatsby-node.ts

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { glob } from "glob"
44
import { updateCodeData } from "./scripts/update-code-data/update-code-data"
55
import { organizeCodeData } from "./scripts/update-code-data/organize-code-data"
66
import { sortCodeData } from "./scripts/update-code-data/sort-code-data"
7+
import redirects from "./redirects.json"
78

89
export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"] =
910
async ({ actions }) => {
@@ -128,6 +129,15 @@ export const createPages: GatsbyNode["createPages"] = async ({
128129
statusCode: 200,
129130
})
130131

132+
// legacy 301 redirects from previous iterations of the site
133+
redirects.forEach(({ from, to }) => {
134+
createRedirect({
135+
fromPath: from,
136+
toPath: to,
137+
statusCode: 301,
138+
})
139+
})
140+
131141
const result = await graphql(`
132142
query allMarkdownRemark {
133143
allMarkdownRemark {

redirects.json

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[
2+
{
3+
"from": "/docs/api-reference-errors",
4+
"to": "/graphql-js/error/"
5+
},
6+
{
7+
"from": "/docs/api-reference-execution",
8+
"to": "/graphql-js/execution/"
9+
},
10+
{
11+
"from": "/docs/api-reference-express-graphql",
12+
"to": "/graphql-js/express-graphql/"
13+
},
14+
{
15+
"from": "/docs/api-reference-graphql",
16+
"to": "/graphql-js/graphql/"
17+
},
18+
{
19+
"from": "/docs/api-reference-language",
20+
"to": "/graphql-js/language/"
21+
},
22+
{
23+
"from": "/docs/api-reference-type-system",
24+
"to": "/graphql-js/type/"
25+
},
26+
{
27+
"from": "/docs/api-reference-type-utilities",
28+
"to": "/graphql-js/utilities/"
29+
},
30+
{
31+
"from": "/docs/api-reference-type-validation",
32+
"to": "/graphql-js/validation/"
33+
},
34+
{
35+
"from": "/docs/getting-started",
36+
"to": "/learn/"
37+
},
38+
{
39+
"from": "/docs/intro",
40+
"to": "/learn/"
41+
},
42+
{
43+
"from": "/docs/introspection",
44+
"to": "/learn/introspection/"
45+
},
46+
{
47+
"from": "/docs/queries",
48+
"to": "/learn/queries/"
49+
},
50+
{
51+
"from": "/docs/typesystem",
52+
"to": "/learn/schema/"
53+
},
54+
{
55+
"from": "/docs/validation",
56+
"to": "/learn/validation/"
57+
},
58+
{
59+
"from": "/docs/videos",
60+
"to": "/community/#videos/"
61+
},
62+
{
63+
"from": "/help",
64+
"to": "/community/"
65+
}
66+
]

static/_redirects

-25
This file was deleted.

0 commit comments

Comments
 (0)