Skip to content

Commit 667a979

Browse files
committedOct 23, 2024
feat: no search entries found page (#5372)
1 parent 4a8e68b commit 667a979

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed
 

‎assets/icons/search-not-found.png

40.7 KB
Loading

‎assets/js/registrySearch.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ function executeSearch(searchQuery) {
137137
let results = miniSearch.search(searchQuery);
138138
document.getElementById('search-loading').style.display = 'none';
139139

140-
if (results.length > 0) {
141-
populateResults(results);
142-
} else {
143-
document.querySelector('#search-results').innerHTML +=
144-
'<p>No matches found</p>';
145-
}
140+
if (results.length === 0) {
141+
document.getElementById('no-search-result').style.display = 'block';
142+
}
143+
144+
populateResults(results);
145+
146146
}, 0);
147147
};
148148

‎layouts/shortcodes/ecosystem/registry/search-form.html

+14
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@
9797
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
9898
<span role="status">Loading results…</span>
9999
</div>
100+
101+
<!-- When search hs no result -->
102+
<div style="display: none; padding:20px; text-align: center;" id="no-search-result">
103+
<div style="margin-left: auto; margin-right: auto; width: fit-content;">
104+
{{ with resources.Get "icons/search-not-found.png" }}
105+
<img style="border: none;" src="{{ .RelPermalink }}" width="250" alt="no result found">
106+
{{ end }}
107+
</div>
108+
<p style="color: #4f62ad; font-size: 28px; margin-bottom: 0;">Oops no results found</p>
109+
<p>No results match the filter criteria. Remove filter or clear all filters to show results</p>
110+
<button type="button" class="btn btn-outline-danger"
111+
onclick="document.getElementById('input-s').value = ''; document.getElementById('input-language').value = 'all';document.getElementById('input-component').value = 'all';document.getElementById('searchForm').submit();">Reset filters</button>
112+
</div>
113+
100114
<ul class="list-unstyled" id="search-results"></ul>
101115
<ul class="list-unstyled" id="default-body">
102116
{{ range $key, $value := $registry -}}

0 commit comments

Comments
 (0)