summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok cheetah2020-05-23 17:30:03 +0200
committeruvok cheetah2020-05-23 17:30:03 +0200
commit5231bb9a84d177948a5fde46a0d8e2cb7adcb7ea (patch)
treebe32c102af732e10a85531dbc9bbd503db46831a
parentfd1004ff9bc4e30729a3be36d6bc7ad83518aac2 (diff)
Make search return page instead of match
-rw-r--r--assets/js/search.js3
-rw-r--r--search.html8
2 files changed, 6 insertions, 5 deletions
diff --git a/assets/js/search.js b/assets/js/search.js
index 8784541..8584810 100644
--- a/assets/js/search.js
+++ b/assets/js/search.js
@@ -26,5 +26,6 @@ var idx = lunr(function () {
function do_search(queryterm) {
- return idx.search(queryterm);
+ const result = idx.search(queryterm);
+ return result.map(r => pages.find((p) => p.id === r.ref));
}
diff --git a/search.html b/search.html
index 99b8203..39bf90f 100644
--- a/search.html
+++ b/search.html
@@ -25,14 +25,14 @@ in_navbar: true
rbase.textContent = "";
if (result.length) {
var root = rbase.appendChild(document.createElement("ul"));
- result.forEach(function(r) {
- const p = pages.find((p) => p.id === r.ref);
+ result.forEach(function(p) {
var li = document.createElement("li");
var el = li.appendChild(document.createElement("a"));
el.textContent = p.title;
el.href = p.url;
- el = li.appendChild(document.createElement("span"));
- el.textContent = " [score: " + r.score.toString() + "]";
+ // converted to page, to more score
+ /*el = li.appendChild(document.createElement("span"));
+ el.textContent = " [score: " + r.score.toString() + "]";*/
root.appendChild(li);
});
} else {