File tree Expand file tree Collapse file tree 1 file changed +36
-12
lines changed Expand file tree Collapse file tree 1 file changed +36
-12
lines changed Original file line number Diff line number Diff line change @@ -172,18 +172,42 @@ export function Search({
172172 return ;
173173 }
174174
175- const queryResults = await search . query (
176- inputQuery ,
177- {
178- path,
179- platforms : currentSearchPlatforms . map (
180- platform => standardSDKSlug ( platform ) ?. slug ?? ''
181- ) ,
182- searchAllIndexes : showOffsiteResults ,
183- ...args ,
184- } ,
185- { clickAnalytics : true , analyticsTags : [ 'source:documentation' ] }
186- ) ;
175+ const queryResults = await search
176+ . query (
177+ inputQuery ,
178+ {
179+ path,
180+ platforms : currentSearchPlatforms . map (
181+ platform => standardSDKSlug ( platform ) ?. slug ?? ''
182+ ) ,
183+ searchAllIndexes : showOffsiteResults ,
184+ ...args ,
185+ } ,
186+ { clickAnalytics : true , analyticsTags : [ 'source:documentation' ] }
187+ )
188+ . then ( siteResults => {
189+ if ( isDeveloperDocs ) {
190+ return siteResults ;
191+ }
192+ return siteResults . map ( site => {
193+ if ( site . site !== 'docs' ) {
194+ return site ;
195+ }
196+ return {
197+ ...site ,
198+ // put API results last
199+ hits : site . hits . sort ( ( a , b ) => {
200+ if ( a . url . includes ( '/api/' ) && ! b . url . includes ( '/api/' ) ) {
201+ return 1 ;
202+ }
203+ if ( b . url . includes ( '/api/' ) && ! a . url . includes ( '/api/' ) ) {
204+ return - 1 ;
205+ }
206+ return 0 ;
207+ } ) ,
208+ } ;
209+ } ) ;
210+ } ) ;
187211
188212 if ( loading ) {
189213 setLoading ( false ) ;
You can’t perform that action at this time.
0 commit comments