-
Notifications
You must be signed in to change notification settings - Fork 3
chore: Add redirects #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
chore: Add redirects #271
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1fb8850
Adding redirects. See description.
colinmurphy 91b6beb
Added redirects for 404 when searching for site:faust.org on Google
colinmurphy a2e1447
Merge branch 'toolkit' into chore-add-old-site-redirects
colinmurphy 37d26c3
Tidied up redirects
colinmurphy 35eaf86
Updated logic to throw 404 when the post isn't found.
colinmurphy 9b81e71
Migrated redirects to a JS file as per code review from @moonmeister
colinmurphy d46cb93
Optimising the notFound functionality for a blog page.
colinmurphy a954afb
Moved discord redirects back into main next config file for readability.
colinmurphy 04edb44
Added missing config. Renamed redirects file to redirects-old-site fo…
colinmurphy 212aeb6
Fixed small linting issue
colinmurphy ee8b87b
Update src/pages/blog/[slug].jsx
moonmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,69 @@ | ||
| import fs from "node:fs"; | ||
|
|
||
| const GRAPHQL_ENDPOINT = "https://faustjsorg.wpengine.com/graphql"; | ||
|
|
||
| const QUERY = `{ | ||
| posts(first: 200) { | ||
| nodes { | ||
| uri | ||
| } | ||
| } | ||
| showcases { | ||
| nodes { | ||
| uri | ||
| } | ||
| } | ||
| }`; | ||
|
|
||
| async function createRedirectFile($filename) { | ||
| try { | ||
| const response = await fetch(GRAPHQL_ENDPOINT, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ query: QUERY }), | ||
| }); | ||
|
|
||
| const { data } = await response.json(); | ||
|
|
||
| if (!data) throw new Error("No data returned from WPGraphQL."); | ||
|
|
||
| const nonMigratedPosts = new Set([ | ||
| "/faust-we-made-contact/", | ||
| "/taking-customer-inspired-up-a-level/", | ||
| "/powered-by-faust/", | ||
| "/faust-update-may-01-2023/", | ||
| "/faust-update-mar-15-2023/", | ||
| "/faust-update-mar-1-2023/", | ||
| "/faust-update-feb-3-2023/", | ||
| "/faust-update-jan-18-2023/", | ||
| "/faust-update-jan-04-2023/", | ||
| "/sprint-24-update/", | ||
| "/sprint-22-update/", | ||
| "/the-future-of-faust/", | ||
| "/ßfaust-update-feb-3-2023/", | ||
| ]); | ||
|
|
||
| const urls = [ | ||
| ...data.posts.nodes.map((post) => ({ | ||
| source: post.uri, | ||
| destination: nonMigratedPosts.has(post.uri) | ||
| ? "/blog/" | ||
| : "/blog" + post.uri, | ||
| permanent: true, | ||
| })), | ||
| ...data.showcases.nodes.map((post) => ({ | ||
| source: post.uri, | ||
| destination: "/showcase/", | ||
| permanent: true, | ||
| })), | ||
| ]; | ||
|
|
||
| await fs.promises.writeFile($filename, JSON.stringify(urls, undefined, 2)); | ||
|
|
||
| console.log("Redirect file created."); | ||
| } catch (error) { | ||
| console.error("Error creating the redirect file. Error:", error); | ||
| } | ||
| } | ||
|
|
||
| await createRedirectFile("redirects-old-site.json"); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.