Skip to content

Commit

Permalink
Merge branch 'develop' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat-patodi authored Jul 26, 2020
2 parents 2f262cb + 78775b6 commit 94643bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/plugins/search/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unused-vars */
import { init as initComponet, update as updateComponent } from './component';
import { init as initComponent, update as updateComponent } from './component';
import { init as initSearch } from './search';

const CONFIG = {
Expand Down Expand Up @@ -32,7 +32,7 @@ const install = function(hook, vm) {
const isAuto = CONFIG.paths === 'auto';

hook.mounted(_ => {
initComponet(CONFIG, vm);
initComponent(CONFIG, vm);
!isAuto && initSearch(CONFIG, vm);
});
hook.doneEach(_ => {
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ export function search(query) {
'...' +
escapeHtml(postContent)
.substring(start, end)
.replace(regEx, `<em class="search-keyword">${keyword}</em>`) +
.replace(
regEx,
word => `<em class="search-keyword">${word}</em>`
) +
'...';

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

// Fix search error when exist translations documents
if (INDEXS !== null && !INDEXS[paths[0]]) {
INDEXS = {};
}

paths.forEach(path => {
if (INDEXS[path]) {
return count++;
Expand Down

0 comments on commit 94643bc

Please sign in to comment.