@@ -9,18 +9,22 @@ const DocumentPage = {
99</div>
1010` ,
1111 data : function ( ) {
12+ const route = normalizeRoute ( this . $route ) ;
13+
1214 return {
13- document : this . $ route. params . document ,
14- hash : this . $ route. hash ,
15+ document : route . document ,
16+ hash : route . hash ,
1517 locale : $cookies . get ( "locale" ) || "en" ,
1618 readLink : "https://raw.githubusercontent.com/typeorm/typeorm/master/" ,
1719 editLink : "https://github.com/typeorm/typeorm/edit/master/"
1820 } ;
1921 } ,
2022 watch : {
2123 '$route' : function ( to , from ) {
22- this . document = to . params . document ;
23- this . hash = to . hash ;
24+ const route = normalizeRoute ( to ) ;
25+
26+ this . document = route . document ;
27+ this . hash = route . hash ;
2428 this . updateTitle ( ) ;
2529 }
2630 } ,
@@ -59,3 +63,26 @@ const DocumentPage = {
5963 }
6064 }
6165} ;
66+
67+ // Treat https://typeorm.io/?route=%2Fentities%23what-is-entity as https://typeorm.io/entities#what-is-entity
68+ // This is used for Algolia DocSearch crawler indexing as a workaround
69+ // for the site being a single page app while utilizing a 404 page for that
70+ function normalizeRoute ( route ) {
71+ let document = route . params . document ;
72+ let hash = route . hash ;
73+
74+ if ( route . query != null && route . query [ "route" ] != null ) {
75+ const url = new URL ( window . location . origin + route . query [ "route" ] ) ;
76+ document = url . pathname . split ( "/" ) [ 1 ] ;
77+
78+ if ( document == null )
79+ document = route . params . document ;
80+ else
81+ hash = url . hash ;
82+ }
83+
84+ return {
85+ document,
86+ hash,
87+ } ;
88+ }
0 commit comments