@@ -318,7 +318,10 @@ document.addEventListener("DOMContentLoaded", function () {
318318 }
319319 resultsElement . classList . remove ( 'hx:hidden' ) ;
320320
321- const pageResults = window . pageIndex . search ( query , 5 , { enrich : true , suggest : true } ) [ 0 ] ?. result || [ ] ;
321+ // Configurable search limits with sensible defaults
322+ const maxPageResults = parseInt ( '{{- site.Params.search.flexsearch.maxPageResults | default 20 -}}' , 10 ) ;
323+ const maxSectionResults = parseInt ( '{{- site.Params.search.flexsearch.maxSectionResults | default 10 -}}' , 10 ) ;
324+ const pageResults = window . pageIndex . search ( query , maxPageResults , { enrich : true , suggest : true } ) [ 0 ] ?. result || [ ] ;
322325
323326 const results = [ ] ;
324327 const pageTitleMatches = { } ;
@@ -328,11 +331,12 @@ document.addEventListener("DOMContentLoaded", function () {
328331 pageTitleMatches [ i ] = 0 ;
329332
330333 // Show the top 5 results for each page
331- const sectionResults = window . sectionIndex . search ( query , 5 , { enrich : true , suggest : true , tag : { 'pageId' : `page_${ result . id } ` } } ) [ 0 ] ?. result || [ ] ;
334+ const sectionResults = window . sectionIndex . search ( query , { enrich : true , suggest : true , tag : { 'pageId' : `page_${ result . id } ` } } ) [ 0 ] ?. result || [ ] ;
332335 let isFirstItemOfPage = true
333336 const occurred = { }
334337
335- for ( let j = 0 ; j < sectionResults . length ; j ++ ) {
338+ const nResults = Math . min ( sectionResults . length , maxSectionResults ) ;
339+ for ( let j = 0 ; j < nResults ; j ++ ) {
336340 const { doc } = sectionResults [ j ]
337341 const isMatchingTitle = doc . display !== undefined
338342 if ( isMatchingTitle ) {
0 commit comments