@@ -315,7 +315,9 @@ <h1><a href="https://threejs.org">three.js</a></h1>
315315 }
316316
317317 const regExp = new RegExp ( escapeRegExp ( v ) , 'gi' ) ;
318- const highlightRegExp = new RegExp ( v . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) , 'gi' ) ;
318+ // Create highlight regex that matches any of the search words
319+ const words = v . split ( ' ' ) . map ( word => word . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ) . join ( '|' ) ;
320+ const highlightRegExp = new RegExp ( words , 'gi' ) ;
319321
320322 // Search through all categories
321323 const results = [ ] ;
@@ -324,7 +326,9 @@ <h1><a href="https://threejs.org">three.js</a></h1>
324326 const items = searchData [ category ] ;
325327 for ( const item of items ) {
326328
327- if ( item . title . match ( regExp ) ) {
329+ // Match against combined category and title for multi-word searches
330+ const searchText = category + ' ' + item . title ;
331+ if ( searchText . match ( regExp ) ) {
328332
329333 results . push ( { ...item , category } ) ;
330334
@@ -414,7 +418,8 @@ <h1><a href="https://threejs.org">three.js</a></h1>
414418
415419 if ( ! byCategory [ category ] ) continue ;
416420
417- html += `<h2>${ category } </h2>` ;
421+ const highlightedCategory = highlightMatch ( category , highlightRegExp ) ;
422+ html += `<h2>${ highlightedCategory } </h2>` ;
418423
419424 for ( const className in byCategory [ category ] ) {
420425
0 commit comments