From 87d1db760f62dad180e1ac9aa2a567d5ff1c544b Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 15 Mar 2022 08:56:08 -0400 Subject: [PATCH] improve search results --- docs/assets/plugins/search/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/assets/plugins/search/search.js b/docs/assets/plugins/search/search.js index a99ee72f..937a89c6 100644 --- a/docs/assets/plugins/search/search.js +++ b/docs/assets/plugins/search/search.js @@ -219,11 +219,11 @@ await searchIndex; const hasQuery = query.length > 0; - const searchQuery = query + const searchTokens = query .split(' ') .map((term, index, arr) => `${term}${index === arr.length - 1 ? `* ${term}~1` : '~1'}`) .join(' '); - const matches = hasQuery ? searchIndex.search(searchQuery) : []; + const matches = hasQuery ? searchIndex.search(`${query} ${searchTokens}`) : []; const hasResults = hasQuery && matches.length > 0; siteSearch.classList.toggle('site-search--has-results', hasQuery && hasResults); siteSearch.classList.toggle('site-search--no-results', hasQuery && !hasResults);