File tree Expand file tree Collapse file tree 2 files changed +47
-6
lines changed Expand file tree Collapse file tree 2 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -198,12 +198,7 @@ export default defineConfig({
198198 } ,
199199 } ) ,
200200 starlightDocSearch ( {
201- appId : 'XBW1JU7CW5' ,
202- apiKey : '6b0341e2f50196d328d088dbb5cd6166' ,
203- indexName : 'localstack' ,
204- searchParameters : {
205- facets : [ 'lvl0' ] ,
206- } ,
201+ clientOptionsModule : './src/config/docsearch.ts' ,
207202 } ) ,
208203 ] ,
209204 sidebar : [
Original file line number Diff line number Diff line change 1+ import type { DocSearchClientOptions } from '@astrojs/starlight-docsearch' ;
2+
3+ export default {
4+ appId : 'XBW1JU7CW5' ,
5+ apiKey : '6b0341e2f50196d328d088dbb5cd6166' ,
6+ indexName : 'localstack' ,
7+ searchParameters : {
8+ facets : [ 'lvl0' ] ,
9+ } ,
10+ transformSearchClient ( searchClient ) {
11+ return {
12+ ...searchClient ,
13+ search ( requests : any ) {
14+ // Get the current pathname at runtime
15+ const pathname = typeof window !== 'undefined' ? window . location . pathname : '' ;
16+
17+ // Determine the boost filter based on pathname
18+ let boostFilter : string | null = null ;
19+ if ( pathname . startsWith ( '/aws/' ) ) {
20+ boostFilter = "hierarchy.lvl0:LocalStack for AWS" ;
21+ } else if ( pathname . startsWith ( '/snowflake/' ) ) {
22+ boostFilter = "hierarchy.lvl0:LocalStack for Snowflake" ;
23+ }
24+
25+ if ( ! boostFilter ) {
26+ return searchClient . search ( requests ) ;
27+ }
28+
29+ if ( ! requests || typeof requests !== 'object' || ! Array . isArray ( requests . requests ) ) {
30+ return searchClient . search ( requests ) ;
31+ }
32+
33+ const transformedRequests = {
34+ ...requests ,
35+ requests : requests . requests . map ( ( request : any ) => ( {
36+ ...request ,
37+ optionalFilters : [ boostFilter ] ,
38+ sumOrFiltersScores : true ,
39+ } ) ) ,
40+ } ;
41+
42+ return searchClient . search ( transformedRequests ) ;
43+ } ,
44+ } ;
45+ } ,
46+ } satisfies DocSearchClientOptions ;
You can’t perform that action at this time.
0 commit comments