@@ -5,6 +5,7 @@ import CategoriesMapModel from '../api/models/CategoriesMapModel'
5
5
import EventModel from '../api/models/EventModel'
6
6
import ExtendedPageModel from '../api/models/ExtendedPageModel'
7
7
import PoiModel from '../api/models/PoiModel'
8
+ import normalizeString from '../utils/normalizeString'
8
9
9
10
export type SearchResult = ExtendedPageModel
10
11
const DEBOUNCED_QUERY_TIMEOUT = 250
@@ -23,13 +24,14 @@ export const prepareSearchDocuments = (
23
24
// Modifying single documents or replacing documents with a same length array will therefore NOT trigger an update
24
25
const useSearch = ( documents : SearchResult [ ] , query : string ) : SearchResult [ ] => {
25
26
const [ indexing , setIndexing ] = useState ( false )
26
- const [ debouncedQuery , setDebouncedQuery ] = useState ( query )
27
+ const [ debouncedQuery , setDebouncedQuery ] = useState ( normalizeString ( query ) )
27
28
28
29
const [ search ] = useState (
29
30
new MiniSearch ( {
30
31
idField : 'path' ,
31
32
fields : [ 'title' , 'content' ] ,
32
33
storeFields : [ 'title' , 'content' , 'path' , 'thumbnail' ] ,
34
+ processTerm : normalizeString ,
33
35
searchOptions : {
34
36
boost : { title : 2 } ,
35
37
fuzzy : true ,
@@ -40,7 +42,7 @@ const useSearch = (documents: SearchResult[], query: string): SearchResult[] =>
40
42
41
43
useEffect ( ( ) => {
42
44
const debounceQueryTimeout = setTimeout ( ( ) => {
43
- setDebouncedQuery ( query )
45
+ setDebouncedQuery ( normalizeString ( query ) )
44
46
} , DEBOUNCED_QUERY_TIMEOUT )
45
47
46
48
return ( ) => clearTimeout ( debounceQueryTimeout )
0 commit comments