From 4589694b4df0a60f77800268b59d65351b6dbbb7 Mon Sep 17 00:00:00 2001 From: zonemeen <994718917@qq.com> Date: Sun, 17 Mar 2024 23:20:14 +0800 Subject: [PATCH] fix(localSearch): remove empty title from search results --- src/node/plugins/localSearchPlugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/plugins/localSearchPlugin.ts b/src/node/plugins/localSearchPlugin.ts index e94eafb7..c223c326 100644 --- a/src/node/plugins/localSearchPlugin.ts +++ b/src/node/plugins/localSearchPlugin.ts @@ -235,8 +235,9 @@ function* splitPageIntoSections(html: string) { const anchor = headingResult?.[2] ?? '' const content = result[i + 2] if (!title || !content) continue - const titles = parentTitles.slice(0, level) + let titles = parentTitles.slice(0, level) titles[level] = title + titles = titles.filter(Boolean) yield { anchor, titles, text: getSearchableText(content) } if (level === 0) { parentTitles = [title]