mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-17 00:22:24 -06:00
Add fuzzy search if no results were found
This commit is contained in:
parent
b13b44f18b
commit
e2e01effa6
@ -154,6 +154,15 @@ function searchLoaded(index, docs) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ((results.length == 0) && (input.length > 2)) {
|
||||||
|
results = index.query(function (query) {
|
||||||
|
var tokens = lunr.tokenizer(input)
|
||||||
|
query.term(tokens, {
|
||||||
|
editDistance: Math.round(Math.sqrt(input.length / 2 - 1))
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (results.length == 0) {
|
if (results.length == 0) {
|
||||||
var noResultsDiv = document.createElement('div');
|
var noResultsDiv = document.createElement('div');
|
||||||
noResultsDiv.classList.add('search-no-result');
|
noResultsDiv.classList.add('search-no-result');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user