Highlight terms in search result titles#679
Highlight terms in search result titles#679RisingOrange wants to merge 2 commits intoPauseAI:mainfrom
Conversation
👷 Deploy request for pauseai pending review.Visit the deploys page to approve it
|
989ccb6 to
22b9c15
Compare
|
For reference: The default weight of h1 elements is 7, but it probably doesn't hurt to boost it further. |
|
Also, I just found an unreleased PR handling the exact case described in the issue: Pagefind/pagefind#1003 |
22b9c15 to
c8761c6
Compare
9227b30 to
589ac57
Compare
11b3c61 to
abc17e2
Compare
Right, this seems to be a very good fit for what we want. For now, we could just add the match highlighting in titles? I updated the PR description. |
abc17e2 to
d30db19
Compare
d30db19 to
b7ae11d
Compare
b7ae11d to
146dfeb
Compare
|
While working on the title highlighting, I noticed that match highlighting needs to be more complicated than I expected in order to support Unicode. |
Summary
This PR makes search results easier to scan by highlighting matched query terms in result titles, so title matching is visually consistent with the excerpt highlighting that Pagefind already provides.
It adds a title-highlighting pass in
Search.sveltethat runs both when the query changes and when Pagefind updates the results DOM. Pagefind highlights terms in result excerpts via{@html}but renders titles as plain text, so this patch post-processes title links to add<mark>tags for the current query.Notes
innerHTML.Español,Zürich, orSão Paulohighlight correctly instead of stopping at ASCII-only word boundaries.anyohighlightsanyone), consistent with how Pagefind highlights matches in excerpts.Screenshots
Query: "lobbying guide"
Query: "if anyone"
Query: "if anyo" (partial word; highlights full word "anyone")