-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from erland-syafiq/redirects
Redirects
- Loading branch information
Showing
17 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const committeeGroups = require("./app/data/committees.json"); | ||
|
||
function getOldSlugFromName(name) { | ||
const normalized = name.replace(/[:(),<>]/g, ""); | ||
const nonSpaceName = normalized.replace(/ /g, "-"); | ||
const url = encodeURIComponent(nonSpaceName); | ||
return url; | ||
} | ||
|
||
module.exports = { | ||
async redirects() { | ||
let redirects = [ | ||
{ | ||
source: "/Home/About", | ||
destination: "/about", | ||
permanent: true | ||
}, | ||
{ | ||
source: "/Applicants/Create", | ||
destination: "/register", | ||
permanent: true | ||
} | ||
]; | ||
|
||
let committees = []; | ||
|
||
for (const group of committeeGroups) { | ||
for (const committee of group.committees) { | ||
committees.push(committee); | ||
} | ||
} | ||
|
||
const committeeRedirects = committees.map((committee) => { | ||
return { | ||
source: `/Committees/${getOldSlugFromName(committee.committee_name)}`, | ||
destination: `/committees/${committee.id}`, | ||
permanent: true | ||
}; | ||
}); | ||
|
||
redirects = redirects.concat(committeeRedirects); | ||
return redirects; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.