aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/static/js
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2022-01-30 11:41:44 +0100
committerGravatar Leon Sandøy <[email protected]>2022-01-30 11:41:44 +0100
commite53a3a15d0213b3854a3c9619390f0a0e35c4bf6 (patch)
treed377e4c9b188dbe1dfef899e25f41236dc11d346 /pydis_site/static/js
parentAdd redirects for all old resource endpoints. (diff)
Redirects from old endpoints now filter correctly.
For example, navigating to pydis.com/resources/communities will now correctly redirect to pydis.com/resources/?type=community.
Diffstat (limited to 'pydis_site/static/js')
-rw-r--r--pydis_site/static/js/resources.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/pydis_site/static/js/resources.js b/pydis_site/static/js/resources.js
index eaca3978..bf570097 100644
--- a/pydis_site/static/js/resources.js
+++ b/pydis_site/static/js/resources.js
@@ -160,6 +160,14 @@ function updateUI() {
// Executed when the page has finished loading.
document.addEventListener("DOMContentLoaded", function () {
+ /* Check if the user has navigated to one of the old resource pages,
+ like pydis.com/resources/communities. In this case, we'll rewrite
+ the URL before we do anything else. */
+ let resourceTypeInput = $("#resource-type-input").val();
+ if (resourceTypeInput.length !== 0) {
+ window.history.replaceState(null, document.title, `../?type=${resourceTypeInput}`);
+ }
+
// Update the filters on page load to reflect URL parameters.
$('.filter-box-tag').hide();
deserializeURLParams();