-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I hear it can handle Japanese searches, so I'll give it a try 🦖
refs: Support CJK (mutiple language) search #2052 rust-lang/mdBook#2052
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @see https://github.com/HillLiu/docker-mdbook | ||
*/ | ||
window.elasticlunr.Index.load = (index) => { | ||
const FzF = window.fzf.Fzf; | ||
const storeDocs = index.documentStore.docs; | ||
const indexArr = Object.keys(storeDocs); | ||
const ofzf = new FzF(indexArr, { | ||
selector: (item) => { | ||
const res = storeDocs[item]; | ||
res.text = `${res.title}${res.breadcrumbs}${res.body}`; | ||
return res.text; | ||
}, | ||
}); | ||
return { | ||
search: (searchterm) => { | ||
const entries = ofzf.find(searchterm); | ||
return entries.map((data) => { | ||
const { item, score } = data; | ||
return { | ||
doc: storeDocs[item], | ||
ref: item, | ||
score, | ||
}; | ||
}); | ||
}, | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.