forked from redis-developer/redis-developer.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirect.js
40 lines (33 loc) · 905 Bytes
/
redirect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);
},
};
})();