From 1fc2da4fe293f47ec47a7b5d33fa94fa3a06bb3b Mon Sep 17 00:00:00 2001
From: Blake Allen <blakesnake100@gmail.com>
Date: Tue, 26 Oct 2021 23:58:37 +0000
Subject: [PATCH] Merge branch 'hugo' of https://github.com/bur3ku/quartz into hugo

---
 layouts/partials/search.html |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/layouts/partials/search.html b/layouts/partials/search.html
index 78b7765..ce6038f 100644
--- a/layouts/partials/search.html
+++ b/layouts/partials/search.html
@@ -1,7 +1,6 @@
 <div id="search-container">
     <div id="search-space">
-        <input autoComplete="off" id="search-bar" name="search" type="text" aria-label="Search"
-               placeholder="Search for something...">
+        <input autocomplete="off" id="search-bar" name="search" type="text" aria-label="Search" placeholder="Search for something...">
         <div id="results-container">
         </div>
     </div>
@@ -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 `<button class="result-card" id="${url}">
@@ -127,7 +126,7 @@
     }
 
     const redir = (id, term) => {
-        window.location.href = {{.Site.BaseURL}} + `${id}#:~:text=${encodeURIComponent(term)}`
+        window.location.href = "{{.Site.BaseURL}}" + `${id}#:~:text=${encodeURIComponent(term)}`
     }
 
     const source = document.getElementById('search-bar')
@@ -142,8 +141,7 @@
     source.addEventListener('input', (e) => {
         term = e.target.value
         contentIndex.search(term, {
-            limit: 20,
-            depth: 3,
+            limit: 15,
             suggest: true,
         }).then(searchResults => {
             const resultIds = [...new Set(searchResults)]
@@ -175,7 +173,6 @@
 
 
     const searchContainer = document.getElementById("search-container")
-
     function openSearch() {
         if (searchContainer.style.display === "none" || searchContainer.style.display === "") {
             source.value = ""

--
Gitblit v1.10.0