Skip to content

docs - add manual redirects scripts#2178

Merged
lukegalbraithrussell merged 4 commits intomainfrom
luke-redirects-scripts
Jul 31, 2024
Merged

docs - add manual redirects scripts#2178
lukegalbraithrussell merged 4 commits intomainfrom
luke-redirects-scripts

Conversation

@lukegalbraithrussell
Copy link
Contributor

Summary

Docusaurus has a redirects plugin. It doesn't handle redirecting from hashes (like concepts#web-api) which is how the old site worked. I wrote a script to redirect the pages like concepst#web-api to concepts/web-api.

I also used the redirects plugin for normal, specific, redirects.

It seems the two are clashing. With the plugin, and only in prod, /concepts#web-api gets redirect to /concepts/#web-api instead, which doesn't work. Changing trailingSlashes param doesn't fix it. Removing the plugin fixes it, though, so I added an additional redirects script for redirecting specific pages: redirects-pages.js.

The only pages redirected right now are category pages that didn't have content, but are links people might have bookmarked. And /, as there's no landing page yet. All just go to getting-started

I tested it on build and serve, but also the previous iteration worked there. So I also tested the setup on a deployed docusaurus site on a personal repo. It works in prod there.

Requirements

@codecov
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.07%. Comparing base (9b444ae) to head (7160477).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2178   +/-   ##
=======================================
  Coverage   82.07%   82.07%           
=======================================
  Files          18       18           
  Lines        1545     1545           
  Branches      443      443           
=======================================
  Hits         1268     1268           
  Misses        179      179           
  Partials       98       98           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zimeg zimeg added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented docs M-T: Documentation work only labels Jul 31, 2024
Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

LGTM! Testing this in production might be the most sure way to confirm these changes 🚀 😬 These redirects seem fine too but I'd hesitate a bit before adding much more logic around this!

Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think the inner contents of this function can be indented. But this could be ignored. Surprised the linter isn't catching this!

@lukegalbraithrussell lukegalbraithrussell merged commit f636d75 into main Jul 31, 2024
@lukegalbraithrussell lukegalbraithrussell deleted the luke-redirects-scripts branch July 31, 2024 19:42
This was referenced Sep 13, 2024
This was referenced Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented docs M-T: Documentation work only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants