File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
docusaurus-search-local/src/client/theme/SearchPage Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { getStemmedPositions } from "../../utils/getStemmedPositions";
2121import LoadingRing from "../LoadingRing/LoadingRing" ;
2222import { concatDocumentPath } from "../../utils/concatDocumentPath" ;
2323import {
24+ Mark ,
2425 docsPluginIdForPreferredVersion ,
2526 indexDocs ,
2627 searchContextByPaths ,
@@ -226,11 +227,19 @@ function SearchResultItem({
226227 if ( ! isTitle ) {
227228 pathItems . push ( ( page as SearchDocument ) . t ) ;
228229 }
230+ let search = "" ;
231+ if ( Mark && tokens . length > 0 ) {
232+ const params = new URLSearchParams ( ) ;
233+ for ( const token of tokens ) {
234+ params . append ( "_highlight" , token ) ;
235+ }
236+ search = `?${ params . toString ( ) } ` ;
237+ }
229238 return (
230239 < article className = { styles . searchResultItem } >
231240 < h2 >
232241 < Link
233- to = { document . u + ( document . h || "" ) }
242+ to = { document . u + search + ( document . h || "" ) }
234243 dangerouslySetInnerHTML = { {
235244 __html : isContent
236245 ? highlight ( articleTitle , tokens )
You can’t perform that action at this time.
0 commit comments