From c5707cbfb4a36b28a70d484a2ec299bd25647229 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Thu, 7 May 2020 16:36:06 +0800 Subject: [PATCH 1/4] Update search.js --- src/plugins/search/search.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index b1f5f0255..a8384f17b 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -65,6 +65,18 @@ export function genIndex(path, content = '', router, depth) { tokens.forEach(token => { if (token.type === 'heading' && token.depth <= depth) { + const { str, config } = getAndRemoveConfig(token.text); + + let id; + + if (config.id) { + id = config.id; + } else { + id = slugify(escapeHtml(token.text)); + } + + slug = router.toURL(path, { id: id }); + slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) }); index[slug] = { slug, title: token.text, body: '' }; } else { From f74b4f98197a610eeb199d593f73cd9389ca5c16 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Thu, 7 May 2020 16:36:33 +0800 Subject: [PATCH 2/4] Update search.js --- src/plugins/search/search.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index a8384f17b..c2a91de8e 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -76,8 +76,6 @@ export function genIndex(path, content = '', router, depth) { } slug = router.toURL(path, { id: id }); - - slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) }); index[slug] = { slug, title: token.text, body: '' }; } else { if (!slug) { From 73f36824d4c0181770bbbacdf87ec24ca19e71d0 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Thu, 7 May 2020 16:45:41 +0800 Subject: [PATCH 3/4] Update search.js --- src/plugins/search/search.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index c2a91de8e..79c108fe1 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -1,4 +1,6 @@ /* eslint-disable no-unused-vars */ +import { getAndRemoveConfig } from '../../core/render/utils'; + let INDEXS = {}; const LOCAL_STORAGE = { From 49c8919e82b4a6a1e95923ea59d1b66ea396a496 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Fri, 8 May 2020 08:30:48 +0800 Subject: [PATCH 4/4] Update search.js --- src/plugins/search/search.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 79c108fe1..40e70bae3 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -69,16 +69,13 @@ export function genIndex(path, content = '', router, depth) { if (token.type === 'heading' && token.depth <= depth) { const { str, config } = getAndRemoveConfig(token.text); - let id; - if (config.id) { - id = config.id; + slug = router.toURL(path, { id: slugify(config.id) }); } else { - id = slugify(escapeHtml(token.text)); + slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) }); } - slug = router.toURL(path, { id: id }); - index[slug] = { slug, title: token.text, body: '' }; + index[slug] = { slug, title: str, body: '' }; } else { if (!slug) { return;