Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gethugothemes/dot-hugo-documentation-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle J. Kemp <kyle@seiyria.com>2022-06-10 18:07:19 +0300
committerGitHub <noreply@github.com>2022-06-10 18:07:19 +0300
commit9b753303df7da72a1b6f06d3726db9a796f0d2ce (patch)
treeded4c3e154f1a8bf80059f003fb31f5925f96964
parent1d8871d5e5164f2129f16089cc1ddd90523e4a82 (diff)
add autocomplete filtering on label AND value
as it is, trying to filter by the items in the array is frustrating as only the value is filtered on. this change allows for filtering on both.
-rw-r--r--layouts/partials/banner.html7
1 files changed, 7 insertions, 0 deletions
diff --git a/layouts/partials/banner.html b/layouts/partials/banner.html
index e6a620e..1936158 100644
--- a/layouts/partials/banner.html
+++ b/layouts/partials/banner.html
@@ -19,6 +19,13 @@
{{ $currentNode := . }} {{ $currentNode.Scratch.Set "pages" .Site.Pages
}} {{ $pages := ($currentNode.Scratch.Get "pages") }}
<script>
+ $.ui.autocomplete.filter = function (array, term) {
+ var matcher = new RegExp('(^| )' + $.ui.autocomplete.escapeRegex(term), 'i');
+ return $.grep(array, function (value) {
+ return matcher.test(value.label) || matcher.test(value.value) || matcher.test(value);
+ });
+ };
+
$(function() {
var projects = [
{{ range $pages }}