Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2ebb21

Browse files
fix: search titles containing ignored characters (#1395)
* fix: search titles containing ignored characters* fix* add default value* add test* fix testCo-authored-by: Koy <koy@ko8e24.top>
1 parent58fbca0 commita2ebb21

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

‎src/plugins/search/search.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function genIndex(path, content = '', router, depth) {
8383
constslugify=window.Docsify.slugify;
8484
constindex={};
8585
letslug;
86+
lettitle='';
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;

‎test/e2e/search.test.js‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,42 @@ describe('Search Plugin Tests', function() {
3535
awaitpage.fill('input[type=search]','test');
3636
awaitexpect(page).toEqualText('.results-panel h2','Test Page');
3737
});
38+
39+
test('search ignore title',async()=>{
40+
constdocsifyInitConfig={
41+
markdown:{
42+
homepage:`
43+
# Hello World
44+
45+
This is the homepage.
46+
`,
47+
sidebar:`
48+
- [Home page](/)
49+
- [GitHub Pages](github)
50+
`,
51+
},
52+
routes:{
53+
'/github.md':`
54+
# GitHub Pages
55+
56+
This is the GitHub Pages.
57+
58+
## GitHub Pages ignore1 <!-- {docsify-ignore} -->
59+
60+
There're three places to populate your docs for your Github repository1.
61+
62+
## GitHub Pages ignore2 {docsify-ignore}
63+
64+
There're three places to populate your docs for your Github repository2.
65+
`,
66+
},
67+
scriptURLs:['/lib/plugins/search.min.js'],
68+
};
69+
awaitdocsifyInit(docsifyInitConfig);
70+
awaitpage.fill('input[type=search]','repository1');
71+
awaitexpect(page).toEqualText('.results-panel h2','GitHub Pages ignore1');
72+
awaitpage.click('.clear-button');
73+
awaitpage.fill('input[type=search]','repository2');
74+
awaitexpect(page).toEqualText('.results-panel h2','GitHub Pages ignore2');
75+
});
3876
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp