Merge branch 'master' of github.com:h-enk/doks

This commit is contained in:
Henk Verlinde 2021-08-12 17:34:59 +02:00
commit 563d4cf726
2 changed files with 33 additions and 24 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@ -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']

View File

@ -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 href><span></span><span></span></a>';
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 = '<a href><span></span><span></span></a>';
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(){