mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2024-12-26 15:05:52 -05:00
feat: add configurable limit to search results (#1281)
* feat: add configurable limit to search results Signed-off-by: Navendu Pottekkat <navendu@apache.org> * Handle case where params.fuseOpts is not defined resulting into `Cannot read properties of null (reading 'limit')` Utilizes search options by fuse https://www.fusejs.io/api/methods.html#search The options: limit (type: number): Denotes the max number of returned search results. --------- Signed-off-by: Navendu Pottekkat <navendu@apache.org> Co-authored-by: Aditya Telange <21258296+adityatelange@users.noreply.github.com>
This commit is contained in:
parent
ac1e041419
commit
f7bd1ec07c
@ -77,7 +77,12 @@ sInput.onkeyup = function (e) {
|
||||
// run a search query (for "term") every time a letter is typed
|
||||
// in the search box
|
||||
if (fuse) {
|
||||
const results = fuse.search(this.value.trim()); // the actual query being run using fuse.js
|
||||
let results;
|
||||
if (params.fuseOpts) {
|
||||
results = fuse.search(this.value.trim(), {limit: params.fuseOpts.limit}); // the actual query being run using fuse.js along with options
|
||||
} else {
|
||||
results = fuse.search(this.value.trim()); // the actual query being run using fuse.js
|
||||
}
|
||||
if (results.length !== 0) {
|
||||
// build our html if result exists
|
||||
let resultSet = ''; // our results bucket
|
||||
|
Loading…
Reference in New Issue
Block a user