@@ -70,6 +70,11 @@ function attach_elastic_search_query_sphinx(data) {
70
70
}
71
71
72
72
var link = result . path + "?highlight=" + $ . urlencode ( query ) ;
73
+ // If we aren't on the main domain of the subproject, link to it.
74
+ // TODO: we should always redirect to the main domain instead.
75
+ if ( result . path . startsWith ( '/projects/' ) && ! window . location . href . startsWith ( result . domain ) ) {
76
+ link = result . domain + link ;
77
+ }
73
78
74
79
var item = $ ( '<a>' , { 'href' : link } ) ;
75
80
@@ -289,9 +294,16 @@ function attach_elastic_search_query_mkdocs(data) {
289
294
var result = results [ i ] ;
290
295
var blocks = result . blocks ;
291
296
297
+ var link = result . path ;
298
+ // If we aren't on the main domain of the subproject, link to it.
299
+ // TODO: we should always redirect to the main domain instead.
300
+ if ( result . path . startsWith ( '/projects/' ) && ! window . location . href . startsWith ( result . domain ) ) {
301
+ link = result . domain + link ;
302
+ }
303
+
292
304
var item = $ ( '<article>' ) ;
293
305
item . append (
294
- $ ( '<h3>' ) . append ( $ ( '<a>' , { 'href' : result . path , 'text' : result . title } ) )
306
+ $ ( '<h3>' ) . append ( $ ( '<a>' , { 'href' : link , 'text' : result . title } ) )
295
307
) ;
296
308
297
309
if ( result . project !== project ) {
@@ -303,7 +315,7 @@ function attach_elastic_search_query_mkdocs(data) {
303
315
var section = blocks [ j ] ;
304
316
305
317
if ( section . type === 'section' ) {
306
- var section_link = result . path + '#' + section . id ;
318
+ var section_link = link + '#' + section . id ;
307
319
var section_title = section . title ;
308
320
var section_content = section . content ;
309
321
if ( section_content . length > MAX_SUBSTRING_LIMIT ) {
0 commit comments