Skip to content

Commit 03fda8b

Browse files
Merge branch 'develop' into feature-customizableSidebarItemName
2 parents 5a1e655 + 9832805 commit 03fda8b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/core/util/str.js

+9
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ export function startsWith(str, prefix) {
55
export function endsWith(str, suffix) {
66
return str.indexOf(suffix, str.length - suffix.length) !== -1;
77
}
8+
9+
export function removeDocsifyIgnoreTag(str) {
10+
return str
11+
.replace(/<!-- {docsify-ignore} -->/, '')
12+
.replace(/{docsify-ignore}/, '')
13+
.replace(/<!-- {docsify-ignore-all} -->/, '')
14+
.replace(/{docsify-ignore-all}/, '')
15+
.trim();
16+
}

src/plugins/search/search.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable no-unused-vars */
22
import { getAndRemoveConfig } from '../../core/render/utils';
3+
import { removeDocsifyIgnoreTag } from '../../core/util/str';
34

45
let INDEXS = {};
56

@@ -89,19 +90,16 @@ export function genIndex(path, content = '', router, depth) {
8990
if (token.type === 'heading' && token.depth <= depth) {
9091
const { str, config } = getAndRemoveConfig(token.text);
9192

93+
const text = removeDocsifyIgnoreTag(token.text);
94+
9295
if (config.id) {
9396
slug = router.toURL(path, { id: slugify(config.id) });
9497
} else {
95-
slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) });
98+
slug = router.toURL(path, { id: slugify(escapeHtml(text)) });
9699
}
97100

98101
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();
102+
title = removeDocsifyIgnoreTag(str);
105103
}
106104

107105
index[slug] = { slug, title: title, body: '' };

0 commit comments

Comments
 (0)