From f7b89db8ee85e54a438db2e2cac3c55e805281c9 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Mon, 25 Oct 2021 15:00:55 -0700 Subject: [PATCH] search fix --- layouts/partials/search.html | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/layouts/partials/search.html b/layouts/partials/search.html index 22b50a182..ce6038fb1 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -1,7 +1,6 @@
- +
@@ -72,6 +71,7 @@ tokenize: "reverse", charset: "latin:extra", suggest: true, + cache: 10, }) const scrapedContent = {{$.Site.Data.contentIndex}} @@ -80,10 +80,10 @@ } const highlight = (content, term) => { - const highlightWindow = 15 + const highlightWindow = 20 const tokenizedTerm = term.split(/\s+/).filter(t => t !== "") const splitText = content.split(/\s+/).filter(t => t !== "") - const includesCheck = (token) => tokenizedTerm.some(term => token.toLowerCase().includes(term.toLowerCase())) + const includesCheck = (token) => tokenizedTerm.some(term => token.toLowerCase().startsWith(term.toLowerCase())) const occurrencesIndices = splitText .map(includesCheck) @@ -116,8 +116,7 @@ } const resultToHTML = ({url, title, content, term}) => { - const md = content.split("---")[2] - const text = removeMarkdown(md) + const text = removeMarkdown(content) const resultTitle = highlight(title, term) const resultText = highlight(text, term) return `