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,