Merge pull request #875 from nwind/master

title 和 path 转成小写避免找不到
This commit is contained in:
liaoxuezhi 2020-08-21 12:19:35 +08:00 committed by GitHub
commit d628d71a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -27,6 +27,7 @@ export default class DocSearch extends React.Component {
}
onSearch(query) {
query = query.toLowerCase();
if (query === '') {
this.setState({searchResults: []});
return;
@ -43,7 +44,13 @@ export default class DocSearch extends React.Component {
.substring(Math.max(0, index - 20), index + 60)
.replace(query, `<strong>${query}</strong>`)
});
} else if (doc.title.indexOf(query) !== -1) {
} else if (doc.title.toLowerCase().indexOf(query) !== -1) {
results.push({
title: doc.title,
path: doc.path,
abstract: ''
});
} else if (doc.path.toLowerCase().indexOf(query) !== -1) {
results.push({
title: doc.title,
path: doc.path,