Skip to content

Commit

Permalink
adding redirect.js :
Browse files Browse the repository at this point in the history
  • Loading branch information
wjohnsto committed Apr 16, 2024
1 parent 8b7ba79 commit 73b934e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';

function tryRedirect() {
if (location.host.includes('learn.')) {
return;
}

let path = location.pathname;

if (!path.startsWith('/')) {
path = `/${path}`;
}

location.replace(`https://redis.io/learn${path}`);
}

export default (function () {
if (!ExecutionEnvironment.canUseDOM) {
return null;
}

return {
onRouteUpdate({ location }) {
console.log(location);

tryRedirect();
setTimeout(tryRedirect, 50);
setTimeout(tryRedirect, 150);
setTimeout(tryRedirect, 250);
setTimeout(tryRedirect, 350);
setTimeout(tryRedirect, 450);
setTimeout(tryRedirect, 550);
setTimeout(tryRedirect, 650);
setTimeout(tryRedirect, 750);
setTimeout(tryRedirect, 850);
setTimeout(tryRedirect, 950);
setTimeout(tryRedirect, 1050);
},
};
})();

0 comments on commit 73b934e

Please sign in to comment.