mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-31 03:45:24 +01: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:
		 Navendu Pottekkat
					Navendu Pottekkat
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							ac1e041419
						
					
				
				
					commit
					f7bd1ec07c
				
			| @@ -77,7 +77,12 @@ sInput.onkeyup = function (e) { | |||||||
|     // run a search query (for "term") every time a letter is typed |     // run a search query (for "term") every time a letter is typed | ||||||
|     // in the search box |     // in the search box | ||||||
|     if (fuse) { |     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) { |         if (results.length !== 0) { | ||||||
|             // build our html if result exists |             // build our html if result exists | ||||||
|             let resultSet = ''; // our results bucket |             let resultSet = ''; // our results bucket | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user