diff options
author | 2022-01-30 11:41:44 +0100 | |
---|---|---|
committer | 2022-01-30 11:41:44 +0100 | |
commit | e53a3a15d0213b3854a3c9619390f0a0e35c4bf6 (patch) | |
tree | d377e4c9b188dbe1dfef899e25f41236dc11d346 /pydis_site/static/js | |
parent | Add 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.js | 8 |
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(); |