Skip to content

Conversation

@colinmurphy
Copy link
Member

What does this do

  1. Adds redirects for blogs and showcases from the old site using a script into "redirects-old-site.json" for old Post type redirects #260
  2. Moved current redirects into "redirects.json"
  3. Updated next.config.mjs to load both json files for redirects
  4. Added 404 redirects after searching for "site:faustjs.org" for Final 404 testing #262
  5. Fixes 500 issues on blog page 500 error for blog post #269

Added function to generate redirects.
Migrated the current redirects into a JSON file and cleaned up next.config.mjs
Added message when a post doesn't exist.
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-chore-add-old-site-redirects https://hx…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@colinmurphy
Copy link
Member Author

One thing to note is I have done a wildcard redirect for /tag/ just in case we ever plan to use tags in the future.

@colinmurphy
Copy link
Member Author

@moonmeister

For reference I will remove the script but I have put this into a gist here - https://gist.github.com/colinmurphy/77aa568da3a16341f4fc4a66384924bb

Copy link
Contributor

@kellenmace kellenmace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for helping us with this, @colinmurphy! My feedback:
I opened this PR expecting to see solely updates to next.config.mjs to accommodate all the redirects we need. I think a simple list of redirects in that file is the approach I'd prefer.

I'm not clear on:

  • Why the generate-redirects-file.js exists in this PR. This looks like a script that could have been useful to programmatically generate some of the redirects, but not something we want to become a permanent part of the codebase.
  • Why the array of JavaScript objects that were in next.config.mjs needed to be converted to JSON and moved to other files, only to have to read those files back in via fs and parse the JSON back into an array of JavaScript objects (what they were in the first place).

It seems to me that simply having an array of JS objects in next.config.mjs is the cleanest option. it could be within the nextConfig object, or as a const at the bottom of the file– either way. What do you think? Thanks.

@colinmurphy
Copy link
Member Author

Thanks for helping us with this, @colinmurphy! My feedback: I opened this PR expecting to see solely updates to next.config.mjs to accommodate all the redirects we need. I think a simple list of redirects in that file is the approach I'd prefer.

I'm not clear on:

  • Why the generate-redirects-file.js exists in this PR. This looks like a script that could have been useful to programmatically generate some of the redirects, but not something we want to become a permanent part of the codebase.
  • Why the array of JavaScript objects that were in next.config.mjs needed to be converted to JSON and moved to other files, only to have to read those files back in via fs and parse the JSON back into an array of JavaScript objects (what they were in the first place).

It seems to me that simply having an array of JS objects in next.config.mjs is the cleanest option. it could be within the nextConfig object, or as a const at the bottom of the file– either way. What do you think? Thanks.

Thanks @kellenmace for the review

  1. The generate-redirects-file.js probably shouldn't be in the PR and I will remove this. Already added it to a gist for reference

  2. Good point about the JSON files and also extracting it out of next.config.mjs. When I had initially created the script for redirects, I had forgotten about redirects in next.config.mjs. So I moved these out into their own files (as the first file could be updated via the script) but in hindsight this should of either been one full JSON file.

I was also following what @moonmeister stated in #260 about Don't just add this massive list to (next.config.mjs) that file is too big as is - create a seperate file listing all the old urls and maybe programatically create the redirects

So I will review the PR now and see which option (file or in the next.config.mjs) makes it easy to read and update.

@colinmurphy
Copy link
Member Author

@kellenmace @moonmeister

Updated the PR as follows.

  1. Removed old script and moved to a gist
  2. Removed the 2 JSON files and just added the redirecrts into next.config.mjs (Also happy to move these all out to a file)
  3. Fixed 404 issue for the blog page

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-chore-add-old-site-redirects https://hx…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@colinmurphy
Copy link
Member Author

@moonmeister @kellenmace @Fran-A-Dev

Updated the PR as per feedback from @moonmeister

  1. Redirects are now in a redirects.js file
  2. These are imported in the next.config.mjs
  3. I also added a small improvement to the 404 logic

Let me know if you need any changes.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-chore-add-old-site-redirects https://hx…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-chore-add-old-site-redirects https://hx…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-chore-add-old-site-redirects https://hx…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-chore-add-old-site-redirects https://hx…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@colinmurphy
Copy link
Member Author

@moonmeister

I did some basic testing on the preview site

  1. Blogs are loading
  2. Issue for when there is no blog is 404ing as expected e.g. https://hxxzhhjluvr7f063hnn444uv6.js.wpenginepowered.com/blog/elewjlejwl/
  3. I checked a few redirects e.g. https://hxxzhhjluvr7f063hnn444uv6.js.wpenginepowered.com/reference/wordpress-plugin-settings/

@moonmeister moonmeister merged commit db41751 into toolkit Feb 18, 2025
3 of 4 checks passed
@moonmeister moonmeister deleted the chore-add-old-site-redirects branch February 18, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants