Merge pull request #181 from seiyria/patch-1

add autocomplete filtering on label AND value
This commit is contained in:
Mehedi Sharif Titas 2022-10-19 14:56:45 +06:00 committed by GitHub
commit c643719b46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 }}