@@ -171,7 +171,11 @@ document.addEventListener('DOMContentLoaded', () => {
171171 setTimeout ( ( ) => {
172172 loadMoreIfNeeded ( ) ;
173173 } , 100 ) ;
174- renderTree ( data . folders , activeSnippets ) ;
174+ const snippetsForTree = activeSnippets . map ( snippet => {
175+ const found = currentSnippets . find ( s => s . id === snippet . id ) ;
176+ return found ? { ...snippet , highlightedName : found . highlightedName } : snippet ;
177+ } ) ;
178+ renderTree ( data . folders , snippetsForTree ) ;
175179
176180 // Update total snippets count
177181 document . getElementById ( 'total-snippets' ) . textContent = `${ activeSnippets . length } snippets` ;
@@ -225,7 +229,9 @@ document.addEventListener('DOMContentLoaded', () => {
225229 highlightedContent : snippet . content . map ( content => ( {
226230 ...content ,
227231 highlightedValue : content . value // No highlighting
228- } ) )
232+ } ) ) ,
233+ highlightedName : snippet . name ,
234+ highlightedDescription : snippet . description
229235 } ) ) ;
230236
231237 // Hide search info bar when no search is active
@@ -271,7 +277,9 @@ document.addEventListener('DOMContentLoaded', () => {
271277 highlightedContent : snippet . highlightedContent || snippet . content . map ( content => ( {
272278 ...content ,
273279 highlightedValue : content . value
274- } ) )
280+ } ) ) ,
281+ highlightedName : highlightSearchMatches ( snippet . name , query ) ,
282+ highlightedDescription : snippet . description ? highlightSearchMatches ( snippet . description , query ) : null
275283 } ) ) ;
276284
277285 currentSnippets = filteredSnippets ;
@@ -467,7 +475,7 @@ document.addEventListener('DOMContentLoaded', () => {
467475
468476 const title = document . createElement ( 'h2' ) ;
469477 title . className = 'text-xl font-semibold text-gray-800 mb-2 dark:text-white' ;
470- title . textContent = snippet . name ;
478+ title . innerHTML = snippet . highlightedName || snippet . name ;
471479 snippetDiv . appendChild ( title ) ;
472480
473481 if ( snippet . tagsIds . length > 0 ) {
@@ -488,7 +496,7 @@ document.addEventListener('DOMContentLoaded', () => {
488496 if ( snippet . description ) {
489497 const desc = document . createElement ( 'p' ) ;
490498 desc . className = 'text-gray-600 mb-2 dark:text-gray-300' ;
491- desc . textContent = snippet . description ;
499+ desc . innerHTML = snippet . highlightedDescription || snippet . description ;
492500 snippetDiv . appendChild ( desc ) ;
493501 }
494502
@@ -678,7 +686,7 @@ document.addEventListener('DOMContentLoaded', () => {
678686 folder . snippets . forEach ( snippet => {
679687 const snippetLi = document . createElement ( 'li' ) ;
680688 snippetLi . className = 'snippet-item' ;
681- snippetLi . textContent = snippet . name ;
689+ snippetLi . innerHTML = snippet . highlightedName || snippet . name ;
682690 snippetLi . dataset . snippetId = snippet . id ;
683691 subUl . appendChild ( snippetLi ) ;
684692 } ) ;
0 commit comments