[fix] algoliasearch is not defined (#542)

This commit is contained in:
星日语 2024-11-19 15:43:35 +08:00 committed by GitHub
parent beb5f3d348
commit 6259ac8e98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 78 additions and 76 deletions

View File

@ -202,6 +202,7 @@ search:
appId: appId:
apiKey: apiKey:
indexName: indexName:
js: https://gcore.jsdelivr.net/algoliasearch/3/algoliasearch.min.js
######## Comments ######## ######## Comments ########

View File

@ -4,10 +4,9 @@
appId: '<%- conf.appId %>', appId: '<%- conf.appId %>',
apiKey: '<%- conf.apiKey %>', apiKey: '<%- conf.apiKey %>',
indexName: '<%- conf.indexName %>', indexName: '<%- conf.indexName %>',
js: '<%- conf.js %>',
hitsPerPage: 100, hitsPerPage: 100,
}; };
utils.js('https://gcore.jsdelivr.net/algoliasearch/3/algoliasearch.min.js', { defer: true });
utils.js('/js/search/algolia-search.js', { defer: true }); utils.js('/js/search/algolia-search.js', { defer: true });
}); });
</script> </script>

View File

@ -1,4 +1,5 @@
utils.jq(() => { utils.js(window.searchConfig.js).then(() => {
utils.jq(() => {
var $inputArea = $("input#search-input"); var $inputArea = $("input#search-input");
if ($inputArea.length === 0) { if ($inputArea.length === 0) {
return; return;
@ -72,4 +73,5 @@ utils.jq(() => {
}); });
observer.observe($resultArea[0], { childList: true }); observer.observe($resultArea[0], { childList: true });
});
}); });