Skip to content

Commit 667804e

Browse files
authored
Redirect to postgraphile.org and build.graphile.org (#458)
* Redirect to postgraphile.org * And for build website
1 parent 41a0308 commit 667804e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

gatsby-browser.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function checkRedirect(inPath) {
2+
const path = inPath.replace(/\/+$/, "");
3+
if (path === "/postgraphile" || path.startsWith("/postgraphile/")) {
4+
const parts = path.split("/");
5+
if (!parts[2]) {
6+
window.location.replace(`https://postgraphile.org`);
7+
} else {
8+
if (parts[2] === "introduction") parts.length = 2;
9+
parts.splice(2, 0, "4");
10+
window.location.replace(`https://postgraphile.org${parts.join("/")}`);
11+
}
12+
}
13+
if (path === "/graphile-build" || path.startsWith("/graphile-build/")) {
14+
const parts = path.split("/");
15+
if (!parts[2]) {
16+
window.location.replace(`https://build.graphile.org`);
17+
} else {
18+
if (parts[2] === "introduction") parts.length = 2;
19+
parts.splice(2, 0, "4");
20+
window.location.replace(`https://build.graphile.org${parts.join("/")}`);
21+
}
22+
}
23+
}
24+
25+
exports.onRouteUpdate = ({ location, prevLocation }) => {
26+
checkRedirect(location.pathname);
27+
};

0 commit comments

Comments
 (0)