mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 06:14:48 +00:00
feat: support common queries in Algolia integration too
Intro experimental 'searchable' front matter param too
This commit is contained in:
1 parent
c937b22f1e
commit
36bc271272
3 files changed
+6
-3
No files matched your search
@@ -22,11 +22,14 @@ if (typeof instantsearch === 'function' && $('#search-box').length) {
|
||||
},
|
||||
searchFunction: function (helper) {
|
||||
let searchResults = document.querySelector('#search-hits');
|
||||
let commonQueries = document.querySelector('#search-common-queries');
|
||||
if (helper.state.query === '') {
|
||||
searchResults.style.display = 'none';
|
||||
commonQueries.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
helper.search();
|
||||
commonQueries.style.display = 'none';
|
||||
searchResults.style.display = 'block';
|
||||
},
|
||||
};
|
||||
@@ -37,7 +40,7 @@ if (typeof instantsearch === 'function' && $('#search-box').length) {
|
||||
search.addWidget(
|
||||
instantsearch.widgets.searchBox({
|
||||
container: '#search-box',
|
||||
autofocus: false,
|
||||
autofocus: true,
|
||||
reset: true,
|
||||
poweredBy: algoliaConfig.poweredBy,
|
||||
placeholder: i18n.placeholder,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
{{- range $pages -}}
|
||||
{{- /* Do not index drafts or private pages. */ -}}
|
||||
{{- if and (not .Draft) (not .Params.private) -}}
|
||||
{{- if and (not .Draft) (not .Params.private) | and (ne .Params.searchable false) -}}
|
||||
|
||||
{{- /* Generate page description. */ -}}
|
||||
{{- $desc := "" -}}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
{{ $search_queries = site.Data.search_queries }}
|
||||
{{end}}
|
||||
|
||||
{{ if eq $search_provider "wowchemy" | and $search_queries }}
|
||||
{{ if $search_queries }}
|
||||
<div id="search-common-queries" class="pt-3">
|
||||
<div class="font-weight-bold pb-3">{{ i18n "search_common_queries" | default "Common searches" }}</div>
|
||||
<ul class="fa-ul">
|
||||
|
||||
Reference in new issue
Block a user