Algolia search update ()

* Search on menu toggle

With that change search is performed when requested. Before it was done
for each pageview, regardless of the fact if search was used by user or
not.

* Localize algolia's empty template
This commit is contained in:
Marcin Pietraszek
2020-07-22 21:34:53 +02:00
committed by GitHub
parent 91433e72e6
commit 28edd82198
2 changed files with 44 additions and 3 deletions

@ -44,11 +44,18 @@ search.addWidget(
instantsearch.widgets.hits({
container: '.search-hits',
templates: {
item: hitTemplate
item: hitTemplate,
empty: '{{ site.data.ui-text[site.locale].search_algolia_no_results | default: "No results" }}',
}
})
);
// Starting the search
search.start();
// Starting the search only when toggle is clicked
$(document).ready(function () {
$(".search__toggle").on("click", function() {
if(!search.started) {
search.start();
}
});
});
</script>