Skip to content

Commit 8fb9165

Browse files
committed
fix
1 parent e30a5f6 commit 8fb9165

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

src/plugins/search/component.js

-19
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,6 @@ function doSearch(value) {
148148

149149
let html = '';
150150
matchs.forEach(post => {
151-
if (/<!-- {docsify-ignore} -->/g.test(post.title)) {
152-
post.title = post.title.replace('<!-- {docsify-ignore} -->', '');
153-
}
154-
155-
if (/{docsify-ignore}/g.test(post.title)) {
156-
post.title = post.title.replace('{docsify-ignore}', '');
157-
}
158-
159-
if (/<!-- {docsify-ignore-all} -->/g.test(post.title)) {
160-
post.title = post.title.replace(
161-
'<!-- {docsify-ignore-all} -->',
162-
''
163-
);
164-
}
165-
166-
if (/{docsify-ignore-all}/g.test(post.title)) {
167-
post.title = post.title.replace('{docsify-ignore-all}', '');
168-
}
169-
170151
html += `<div class="matching-post">
171152
<a href="${post.url}">
172153
<h2>${post.title}</h2>

src/plugins/search/search.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function genIndex(path, content = '', router, depth) {
8383
const slugify = window.Docsify.slugify;
8484
const index = {};
8585
let slug;
86+
let title;
8687

8788
tokens.forEach(token => {
8889
if (token.type === 'heading' && token.depth <= depth) {
@@ -94,7 +95,16 @@ export function genIndex(path, content = '', router, depth) {
9495
slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) });
9596
}
9697

97-
index[slug] = { slug, title: str, body: '' };
98+
if (str) {
99+
title = str
100+
.replace(/<!-- {docsify-ignore} -->/, '')
101+
.replace(/{docsify-ignore}/, '')
102+
.replace(/<!-- {docsify-ignore-all} -->/, '')
103+
.replace(/{docsify-ignore-all}/, '')
104+
.trim();
105+
}
106+
107+
index[slug] = { slug, title: title, body: '' };
98108
} else {
99109
if (!slug) {
100110
return;

0 commit comments

Comments
 (0)