|
1 | 1 | /* eslint-disable no-unused-vars */
|
2 | 2 | import { getAndRemoveConfig } from '../../core/render/utils';
|
| 3 | +import { removeDocsifyIgnoreTag } from '../../core/util/str'; |
3 | 4 |
|
4 | 5 | let INDEXS = {};
|
5 | 6 |
|
@@ -89,19 +90,16 @@ export function genIndex(path, content = '', router, depth) {
|
89 | 90 | if (token.type === 'heading' && token.depth <= depth) {
|
90 | 91 | const { str, config } = getAndRemoveConfig(token.text);
|
91 | 92 |
|
| 93 | + const text = removeDocsifyIgnoreTag(token.text); |
| 94 | + |
92 | 95 | if (config.id) {
|
93 | 96 | slug = router.toURL(path, { id: slugify(config.id) });
|
94 | 97 | } else {
|
95 |
| - slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) }); |
| 98 | + slug = router.toURL(path, { id: slugify(escapeHtml(text)) }); |
96 | 99 | }
|
97 | 100 |
|
98 | 101 | 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); |
105 | 103 | }
|
106 | 104 |
|
107 | 105 | index[slug] = { slug, title: title, body: '' };
|
@@ -213,14 +211,15 @@ export function search(query) {
|
213 | 211 | }
|
214 | 212 |
|
215 | 213 | const matchContent =
|
| 214 | + handlePostContent && |
216 | 215 | '...' +
|
217 |
| - handlePostContent |
218 |
| - .substring(start, end) |
219 |
| - .replace( |
220 |
| - regEx, |
221 |
| - word => `<em class="search-keyword">${word}</em>` |
222 |
| - ) + |
223 |
| - '...'; |
| 216 | + handlePostContent |
| 217 | + .substring(start, end) |
| 218 | + .replace( |
| 219 | + regEx, |
| 220 | + word => `<em class="search-keyword">${word}</em>` |
| 221 | + ) + |
| 222 | + '...'; |
224 | 223 |
|
225 | 224 | resultStr += matchContent;
|
226 | 225 | }
|
|
0 commit comments