chore: search cleanup
This commit is contained in:
parent
72676659be
commit
947affa2ab
3 changed files with 13 additions and 4 deletions
|
@ -110,7 +110,16 @@ window.addEventListener("load", () => {
|
|||
fields: ["title", "tags"],
|
||||
prefix: true,
|
||||
fuzzy: 0.1,
|
||||
boost: { title: 3, tags: 1.5 },
|
||||
boost: { title: 5, tags: 2 },
|
||||
sort: (a, b) => {
|
||||
const exactMatchA =
|
||||
a.title.toLowerCase() === $input.value.trim().toLowerCase();
|
||||
const exactMatchB =
|
||||
b.title.toLowerCase() === $input.value.trim().toLowerCase();
|
||||
if (exactMatchA && !exactMatchB) return -1;
|
||||
if (!exactMatchA && exactMatchB) return 1;
|
||||
return b.score - a.score;
|
||||
},
|
||||
},
|
||||
});
|
||||
const $form = document.querySelector(".search__form");
|
||||
|
|
Reference in a new issue