From b575ca0eea8728f156f2180d2829a6f297e55976 Mon Sep 17 00:00:00 2001 From: Soichi Hayashi Date: Tue, 10 Aug 2021 09:53:17 -0400 Subject: [PATCH 1/2] Update index.js doks was displaying only the very last search result. --- assets/js/index.js | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/assets/js/index.js b/assets/js/index.js index 0df2fd2..248b22b 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -117,39 +117,36 @@ Source: suggestions.addEventListener('click', accept_suggestion, true); function show_results(){ + const maxResult = 5; var value = this.value; - var results = index.search(value, { limit: 5, index: ["content"], enrich: true }); - var entry, childs = suggestions.childNodes; - var i = 0, len = results.length; + var results = index.search(value, {limit: maxResult, enrich: true}); suggestions.classList.remove('d-none'); + suggestions.innerHTML = ""; - results.forEach(function(results) { - - entry = document.createElement('div'); - - entry.innerHTML = ''; - - a = entry.querySelector('a'), - t = entry.querySelector('span:first-child'), - d = entry.querySelector('span:nth-child(2)'); - - // console.log(results); - - a.href = results.result[i].doc.href; - t.textContent = results.result[i].doc.title; - d.textContent = results.result[i].doc.description; - - suggestions.appendChild(entry); - + //flatSearch now returns results for each index field. create a single list + const flatResults = {}; //keyed by href to dedupe results + results.forEach(result=>{ + result.result.forEach(r=>{ + flatResults[r.doc.href] = r.doc; + }); }); - while(childs.length > len){ + //construct a list of suggestions list + for(const href in flatResults) { + const doc = flatResults[href]; - suggestions.removeChild(childs[i]) + const entry = document.createElement('div'); + entry.innerHTML = ''; + + entry.querySelector('a').href = href; + entry.querySelector('span:first-child').textContent = doc.title; + entry.querySelector('span:nth-child(2)').textContent = doc.description; + + suggestions.appendChild(entry); + if(suggestions.childElementCount == maxResult) break; } - } function accept_suggestion(){ From abb93d719cb8173b1aab8475d977d2df98aff40c Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Thu, 12 Aug 2021 17:28:38 +0200 Subject: [PATCH 2/2] Create FUNDING.yml --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b15c6e6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: doks # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']