This repository was archived by the owner on Jul 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-18
lines changed
assets/js/src/typedoc/components Expand file tree Collapse file tree 2 files changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -111,24 +111,16 @@ module typedoc.search {
111111 setLoadingState ( SearchLoadingState . Failure ) ;
112112 return ;
113113 }
114- fetch ( url )
115- . then ( response => {
116- if ( ! response . ok ) {
117- throw new Error ( 'The search index is missing' ) ;
118- }
119114
120- return response . json ( ) ;
121- } )
122- . then ( ( source : IData ) => {
123- data = source ;
124- index = lunr . Index . load ( source . index ) ;
125-
126- initializePriorityResults ( ) ;
127- setLoadingState ( SearchLoadingState . Ready ) ;
128- } )
129- . catch ( ( error ) => {
130- setLoadingState ( SearchLoadingState . Failure ) ;
131- } ) ;
115+ try {
116+ data = window [ 'searchData' ]
117+ index = lunr . Index . load ( data . index ) ;
118+
119+ initializePriorityResults ( ) ;
120+ setLoadingState ( SearchLoadingState . Ready ) ;
121+ } catch ( e ) {
122+ setLoadingState ( SearchLoadingState . Failure ) ;
123+ }
132124 }
133125
134126 /**
@@ -142,7 +134,9 @@ module typedoc.search {
142134 if ( loadingState !== SearchLoadingState . Ready ) return
143135 $results . empty ( )
144136
145- const res = index . search ( query )
137+ // Fuzzy match
138+ // See https://lunrjs.com/docs/lunr.Index.html#~QueryString
139+ const res = index . search ( `*${ query } *` )
146140 for ( let i = 0 , c = Math . min ( 10 , res . length ) ; i < c ; i ++ ) {
147141 const row = data . rows [ res [ i ] . ref ]
148142 let name = row . name
Original file line number Diff line number Diff line change 1818 <link rel =" stylesheet" href =" {{ path }} " >
1919 {{ /each }}
2020 {{ /if }}
21+ <script async src =" {{ relativeURL " assets/js/search.js" }} " id =" search-script" ></script >
2122</head >
2223<body >
2324
You can’t perform that action at this time.
0 commit comments