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

github.com/zzossig/hugo-theme-zzo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzzossig <zzossig@gmail.com>2021-04-20 21:53:59 +0300
committerzzossig <zzossig@gmail.com>2021-04-20 21:53:59 +0300
commit6258d4dde546706fcdb79f7d7060ee75a02a06ad (patch)
tree6adb0b6bcea9de66656f2bcde8643f340404533d
parent272be8ac8836cbd1d595594497810ab8576719d9 (diff)
new param: searchThreshold
-rw-r--r--README.ko.md1
-rw-r--r--exampleSite/config/_default/params.toml1
-rw-r--r--layouts/partials/head/scripts.html4
3 files changed, 5 insertions, 1 deletions
diff --git a/README.ko.md b/README.ko.md
index 6976b79..d05495e 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -273,6 +273,7 @@ enableSearch = true # site search with fuse
enableSearchHighlight = true # when true, search keyword will be highlighted
searchContent = true # include content to search index
searchDistance = 100 # fuse option: distance
+searchThreshold = 0.4 # 0.0: exact match, 1.0: any match
# body
enableBreadcrumb = true # breadcrumb for list, single page
diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml
index 99d6687..2d7b955 100644
--- a/exampleSite/config/_default/params.toml
+++ b/exampleSite/config/_default/params.toml
@@ -36,6 +36,7 @@ enableSearchHighlight = true
searchResultPosition = "main" # side, main
searchContent = true # include content to search index
searchDistance = 100 # fuse option
+searchThreshold = 0.4 # 0.0: exact match, 1.0: any match
# body
enableBreadcrumb = true
diff --git a/layouts/partials/head/scripts.html b/layouts/partials/head/scripts.html
index cf2d608..3f0ba08 100644
--- a/layouts/partials/head/scripts.html
+++ b/layouts/partials/head/scripts.html
@@ -664,6 +664,8 @@
var enableSearch = JSON.parse({{ $enableSearch | jsonify }});
{{ $searchDistance := ($.Param "searchDistance") }}
var searchDistance = JSON.parse({{ $searchDistance | jsonify }});
+ {{ $searchThreshold := ($.Param "searchThreshold") }}
+ var searchThreshold = JSON.parse({{ $searchThreshold | jsonify }});
{{ $searchContent := ($.Param "searchContent") }}
var searchContent = JSON.parse({{ $searchContent | jsonify }});
{{ $enableSearchHighlight := ($.Param "enableSearchHighlight") }}
@@ -694,7 +696,7 @@
searchContent ? ['title', 'description', 'content'] : ['title', 'description'],
includeMatches: enableSearchHighlight,
shouldSort: true, // default: true
- threshold: 0.4, // default: 0.6 (0.0 requires a perfect match)
+ threshold: searchThreshold ? searchThreshold : 0.4, // default: 0.6 (0.0 requires a perfect match)
location: 0, // default: 0
distance: searchDistance ? searchDistance : 100, // default: 100
maxPatternLength: 32,