Skip to content

Commit

Permalink
theme/search: limit to 10 results
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
  • Loading branch information
sumnerevans committed Feb 27, 2025
1 parent 9bb6ac5 commit b387d41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions themes/smol/assets/js/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ document.addEventListener("DOMContentLoaded", async () => {
let searchResults: lunr.Index.Result[] = [];
if (searchString && searchString.length > 2) {
try {
searchResults = lunrSearchIndex!.search(searchString);
searchResults = lunrSearchIndex!.search(searchString).slice(0, 10);
} catch (err) {
searchResultsDiv.innerHTML = `Error: ${err.message}`;
return;
Expand Down Expand Up @@ -100,8 +100,8 @@ document.addEventListener("DOMContentLoaded", async () => {
}
console.time("fetch indexes");
const [indexResp, searchIndexResp] = await Promise.all(
["index.json", "search-index.json"].map((name) =>
fetch(`/${name}?v=${version}&cb=${hash}`, { method: "GET" })
["", "search-"].map((name) =>
fetch(`/${name}index.json?v=${version}&cb=${hash}`, { method: "GET" })
)
);
console.timeEnd("fetch indexes");
Expand Down

0 comments on commit b387d41

Please sign in to comment.