File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 11document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
2+ const { liteClient } = window [ 'algoliasearch/lite' ] ;
3+
4+ const searchClient = liteClient (
5+ '{{ secrets.algoliaAppId }}' ,
6+ '{{ secrets.algoliaAPIKey }}'
7+ ) ;
28 const urlParams = new URLSearchParams ( window . location . search ) ;
39 const queryStr = urlParams . get ( 'query' ) || '' ;
410 const postFeed = document . querySelector ( '.post-feed' ) ;
@@ -18,16 +24,18 @@ document.addEventListener('DOMContentLoaded', async () => {
1824 return mockHits ;
1925 }
2026
21- // eslint-disable-next-line no-undef
22- return index
23- . search ( {
27+ const response = await searchClient . search ( [
28+ {
29+ indexName : '{{ secrets.algoliaIndex }}' ,
2430 query : queryStr ,
25- hitsPerPage : postsPerPage ,
26- page : pageNo
27- } )
28- . then ( ( { hits } = { } ) => {
29- return hits ;
30- } ) ;
31+ params : {
32+ hitsPerPage : postsPerPage ,
33+ page : pageNo
34+ }
35+ }
36+ ] ) ;
37+
38+ return response ?. results [ 0 ] ?. hits ;
3139 } catch ( err ) {
3240 console . log ( err ) ;
3341 err . debugData ? console . log ( err . debugData ) : '' ;
You can’t perform that action at this time.
0 commit comments