From 2efd859f71d14904c8fda0fb24a8f2d2bda66705 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sun, 19 Feb 2017 12:30:49 +0800 Subject: [PATCH] fix(search): fix default config --- src/plugins/search/component.js | 1 + src/plugins/search/index.js | 6 +++--- src/plugins/search/search.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/search/component.js b/src/plugins/search/component.js index 3b349919e..94b7ecce5 100644 --- a/src/plugins/search/component.js +++ b/src/plugins/search/component.js @@ -91,6 +91,7 @@ function bindEvents () { if (!value) { $panel.classList.remove('show') $panel.innerHTML = '' + return } const matchs = search(value) diff --git a/src/plugins/search/index.js b/src/plugins/search/index.js index ea95fdc3b..e1962793f 100644 --- a/src/plugins/search/index.js +++ b/src/plugins/search/index.js @@ -9,7 +9,7 @@ const CONFIG = { const install = function (hook, vm) { const util = Docsify.util - const opts = vm.config.search + const opts = vm.config.search || CONFIG if (Array.isArray(opts)) { CONFIG.paths = opts @@ -23,11 +23,11 @@ const install = function (hook, vm) { hook.mounted(_ => { initComponet(CONFIG) - isAuto && initSearch(CONFIG, vm) + !isAuto && initSearch(CONFIG, vm) }) hook.doneEach(_ => { updateComponent(CONFIG, vm) - !isAuto && initSearch(CONFIG, vm) + isAuto && initSearch(CONFIG, vm) }) } diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 627f043c2..1b18f44d3 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -52,7 +52,7 @@ export function genIndex (path, content = '') { INDEXS[slug] = { slug, title: '', body: '' } } else { if (INDEXS[slug].body) { - INDEXS[slug].body += ('\n' + token.text) + INDEXS[slug].body += '\n' + (token.text || '') } else { INDEXS[slug].body = token.text }