Skip to content

Commit 94643bc

Browse files
Merge branch 'develop' into patch-1
2 parents 2f262cb + 78775b6 commit 94643bc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: src/plugins/search/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-unused-vars */
2-
import { init as initComponet, update as updateComponent } from './component';
2+
import { init as initComponent, update as updateComponent } from './component';
33
import { init as initSearch } from './search';
44

55
const CONFIG = {
@@ -32,7 +32,7 @@ const install = function(hook, vm) {
3232
const isAuto = CONFIG.paths === 'auto';
3333

3434
hook.mounted(_ => {
35-
initComponet(CONFIG, vm);
35+
initComponent(CONFIG, vm);
3636
!isAuto && initSearch(CONFIG, vm);
3737
});
3838
hook.doneEach(_ => {

Diff for: src/plugins/search/search.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ export function search(query) {
170170
'...' +
171171
escapeHtml(postContent)
172172
.substring(start, end)
173-
.replace(regEx, `<em class="search-keyword">${keyword}</em>`) +
173+
.replace(
174+
regEx,
175+
word => `<em class="search-keyword">${word}</em>`
176+
) +
174177
'...';
175178

176179
resultStr += matchContent;
@@ -213,6 +216,11 @@ export function init(config, vm) {
213216
const len = paths.length;
214217
let count = 0;
215218

219+
// Fix search error when exist translations documents
220+
if (INDEXS !== null && !INDEXS[paths[0]]) {
221+
INDEXS = {};
222+
}
223+
216224
paths.forEach(path => {
217225
if (INDEXS[path]) {
218226
return count++;

0 commit comments

Comments
 (0)