The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: flatmap children when highlighting rich preview to avoid body

+3 -3
+3 -3
quartz/components/scripts/search.inline.ts
··· 81 81 }` 82 82 } 83 83 84 - function highlightHTML(searchTerm: string, innerHTML: string) { 84 + function highlightHTML(searchTerm: string, el: HTMLElement) { 85 85 const p = new DOMParser() 86 86 const tokenizedTerms = tokenizeTerm(searchTerm) 87 - const html = p.parseFromString(innerHTML, "text/html") 87 + const html = p.parseFromString(el.innerHTML, "text/html") 88 88 89 89 const createHighlightSpan = (text: string) => { 90 90 const span = document.createElement("span") ··· 389 389 previewInner = document.createElement("div") 390 390 previewInner.classList.add("preview-inner") 391 391 const innerDiv = await fetchContent(slug).then((contents) => 392 - contents.map((el) => highlightHTML(currentSearchTerm, el.innerHTML)), 392 + contents.flatMap((el) => [...highlightHTML(currentSearchTerm, el as HTMLElement).children]), 393 393 ) 394 394 previewInner.append(...innerDiv) 395 395 preview.replaceChildren(previewInner)