Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Oct 14, 2020
1 parent e30a5f6 commit 8fb9165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
19 changes: 0 additions & 19 deletions src/plugins/search/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,6 @@ function doSearch(value) {

let html = '';
matchs.forEach(post => {
if (/<!-- {docsify-ignore} -->/g.test(post.title)) {
post.title = post.title.replace('<!-- {docsify-ignore} -->', '');
}

if (/{docsify-ignore}/g.test(post.title)) {
post.title = post.title.replace('{docsify-ignore}', '');
}

if (/<!-- {docsify-ignore-all} -->/g.test(post.title)) {
post.title = post.title.replace(
'<!-- {docsify-ignore-all} -->',
''
);
}

if (/{docsify-ignore-all}/g.test(post.title)) {
post.title = post.title.replace('{docsify-ignore-all}', '');
}

html += `<div class="matching-post">
<a href="${post.url}">
<h2>${post.title}</h2>
Expand Down
12 changes: 11 additions & 1 deletion src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function genIndex(path, content = '', router, depth) {
const slugify = window.Docsify.slugify;
const index = {};
let slug;
let title;

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

index[slug] = { slug, title: str, body: '' };
if (str) {
title = str
.replace(/<!-- {docsify-ignore} -->/, '')
.replace(/{docsify-ignore}/, '')
.replace(/<!-- {docsify-ignore-all} -->/, '')
.replace(/{docsify-ignore-all}/, '')
.trim();
}

index[slug] = { slug, title: title, body: '' };
} else {
if (!slug) {
return;
Expand Down

0 comments on commit 8fb9165

Please sign in to comment.