Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 443a416

Browse files
manishprivetbenhalverson
authored andcommitted
feat: adding redirects so that links on nodejs.org don't break
Signed-off-by: Manish Kumar <manishprivet@protonmail.com>
1 parent 36ca683 commit 443a416

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

gatsby-node.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path');
33
const fetch = require('node-fetch');
44
const createSlug = require('./util-node/createSlug');
55
const getReleaseStatus = require('./util-node/getReleaseStatus');
6+
const redirects = require('./util-node/redirects');
67

78
const BLOG_POST_FILENAME_REGEX = /([0-9]+)-([0-9]+)-([0-9]+)-(.+)\.md$/;
89

@@ -13,6 +14,14 @@ exports.createPages = ({ graphql, actions }) => {
1314
const docTemplate = path.resolve('./src/templates/learn.tsx');
1415
const blogTemplate = path.resolve('./src/templates/blog.tsx');
1516

17+
Object.keys(redirects).forEach(from => {
18+
createRedirect({
19+
fromPath: from,
20+
toPath: redirects[from],
21+
isPermanent: true,
22+
});
23+
});
24+
1625
resolve(
1726
graphql(
1827
`

util-node/redirects.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This file is used to define all the changed slugs from original nodejs.org site to our new site.
2+
3+
module.exports = {
4+
'/en/get-involved': '/community',
5+
};

0 commit comments

Comments
 (0)