Skip to content

Commit

Permalink
Revert "fix: fix docsify-ignore in seach title. (#1872)"
Browse files Browse the repository at this point in the history
This reverts commit 7fdc484.
  • Loading branch information
Koooooo-7 authored Oct 26, 2022
1 parent 575f8ec commit bc203a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
9 changes: 0 additions & 9 deletions src/core/util/str.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ export function startsWith(str, prefix) {
export function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

export function removeDocsifyIgnoreTag(str) {
return str
.replace(/<!-- {docsify-ignore} -->/, '')
.replace(/{docsify-ignore}/, '')
.replace(/<!-- {docsify-ignore-all} -->/, '')
.replace(/{docsify-ignore-all}/, '')
.trim();
}
12 changes: 7 additions & 5 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-unused-vars */
import { getAndRemoveConfig } from '../../core/render/utils';
import { removeDocsifyIgnoreTag } from '../../core/util/str';

let INDEXS = {};

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

const text = removeDocsifyIgnoreTag(token.text);

if (config.id) {
slug = router.toURL(path, { id: slugify(config.id) });
} else {
slug = router.toURL(path, { id: slugify(escapeHtml(text)) });
slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) });
}

if (str) {
title = removeDocsifyIgnoreTag(str);
title = str
.replace(/<!-- {docsify-ignore} -->/, '')
.replace(/{docsify-ignore}/, '')
.replace(/<!-- {docsify-ignore-all} -->/, '')
.replace(/{docsify-ignore-all}/, '')
.trim();
}

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

0 comments on commit bc203a5

Please sign in to comment.