Skip to content

Commit cbc9e06

Browse files
committed
tweak search
1 parent 28ada45 commit cbc9e06

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎www/_includes/layout.njk‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,16 @@ title: hyperscript
4545
end
4646
end
4747
48-
on input
48+
on input debounced at 200ms
4949
if my value is ''
5050
empty #search-results
5151
add .hidden to #search-results
5252
exit
5353
end
54-
set response to pagefind.debouncedSearch(my value, 200)
55-
if response is null exit
56-
set items to response.results[0 .. 4]
57-
set datas to Promise.all(items.map(\ item -> item.data()))
54+
set response to pagefind.search(my value)
55+
set items to response.results[0 .. 9].map( \ i -> i.data() )
5856
set output to ''
59-
repeat for info in datas
57+
for info in items
6058
set output to output + '<a class=\'search-result\' href=\'' + info.url + '\'>'
6159
+ '<span class=\'search-result-title\'>' + info.meta.title + '</span>'
6260
+ '<span class=\'search-result-excerpt\'>' + info.excerpt + '</span>'
@@ -129,6 +127,7 @@ title: hyperscript
129127
<script type="module">
130128
window.pagefind = await import("/pagefind/pagefind.js");
131129
window.pagefind.init();
130+
window.pagefind.preload('a');
132131
</script>
133132
</body>
134133
</html>

0 commit comments

Comments
 (0)