File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments