diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-16 22:07:21 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-16 22:07:21 +0200 |
| commit | 624fcebe7758611fd9051d286daa362d72cc873f (patch) | |
| tree | f32483bb4cc21558a8fc43a456efb54d62a4e418 | |
| parent | 658bde848b4eefb16e0ecdb68de233677e39d5c9 (diff) | |
| download | gohugo-theme-ed-624fcebe7758611fd9051d286daa362d72cc873f.tar.gz | |
Do not show error if there is no search term
| -rw-r--r-- | assets/js/search.js | 6 | ||||
| -rw-r--r-- | i18n/en.toml | 3 | ||||
| -rw-r--r-- | i18n/ru.toml | 3 | ||||
| -rw-r--r-- | layouts/shortcodes/form-search.html | 2 |
4 files changed, 6 insertions, 8 deletions
diff --git a/assets/js/search.js b/assets/js/search.js index bfb91c8..7fd4d52 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -44,7 +44,6 @@ function handleSearchQuery(event) { const query = document.getElementById('search').value.trim().toLowerCase(); if (!query) { - displayErrorMessage(i18n.enterTerm); hideSearchResults(); return; } @@ -306,4 +305,9 @@ document.addEventListener('DOMContentLoaded', function () { }); searchInput.addEventListener('keyup', (e) => handleSearchQuery(e)); + searchInput.addEventListener('input', (e) => { + if (!e.currentTarget.value) { + hideSearchResults(); + } + }); }); diff --git a/i18n/en.toml b/i18n/en.toml index 24ef81d..6faf598 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -58,9 +58,6 @@ [search_site] other = 'Search site' -[search_enter_term] - other = 'Please enter a search term.' - [search_no_results] other = 'No results found.' diff --git a/i18n/ru.toml b/i18n/ru.toml index dc47e82..cdc6550 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -58,9 +58,6 @@ [search_site] other = 'Поиск по сайту' -[search_enter_term] - other = 'Введите поисковый запрос.' - [search_no_results] other = 'Ничего не найдено.' diff --git a/layouts/shortcodes/form-search.html b/layouts/shortcodes/form-search.html index 403d808..94a951c 100644 --- a/layouts/shortcodes/form-search.html +++ b/layouts/shortcodes/form-search.html @@ -62,7 +62,7 @@ {{- /* Configure search engine. */ -}} {{- $maxSummaryLength := site.Params.search.maxSummaryLength | default 100 -}} {{- $searchConfig := dict "indexURI" ("/index.json" | relLangURL) "maxSummaryLength" $maxSummaryLength -}} -{{- $searchI18n := dict "enterTerm" (i18n "search_enter_term") "noResults" (i18n "search_no_results") -}} +{{- $searchI18n := dict "noResults" (i18n "search_no_results") -}} {{- $searchParams := dict "searchConfig" $searchConfig "i18n" $searchI18n -}} {{- $siteSearch := slice -}} |
