Skip to content

Commit 73b934e

Browse files
committed
adding redirect.js :
1 parent 8b7ba79 commit 73b934e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

redirect.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
2+
3+
function tryRedirect() {
4+
if (location.host.includes('learn.')) {
5+
return;
6+
}
7+
8+
let path = location.pathname;
9+
10+
if (!path.startsWith('/')) {
11+
path = `/${path}`;
12+
}
13+
14+
location.replace(`https://redis.io/learn${path}`);
15+
}
16+
17+
export default (function () {
18+
if (!ExecutionEnvironment.canUseDOM) {
19+
return null;
20+
}
21+
22+
return {
23+
onRouteUpdate({ location }) {
24+
console.log(location);
25+
26+
tryRedirect();
27+
setTimeout(tryRedirect, 50);
28+
setTimeout(tryRedirect, 150);
29+
setTimeout(tryRedirect, 250);
30+
setTimeout(tryRedirect, 350);
31+
setTimeout(tryRedirect, 450);
32+
setTimeout(tryRedirect, 550);
33+
setTimeout(tryRedirect, 650);
34+
setTimeout(tryRedirect, 750);
35+
setTimeout(tryRedirect, 850);
36+
setTimeout(tryRedirect, 950);
37+
setTimeout(tryRedirect, 1050);
38+
},
39+
};
40+
})();

0 commit comments

Comments
 (0)