Skip to content

Commit 0e66834

Browse files
committed
feat: Support search when there is no title
fix docsifyjs#1478
1 parent 47cd86c commit 0e66834

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/plugins/search/search.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function genIndex(path, content = '', router, depth) {
8585
let slug;
8686
let title = '';
8787

88-
tokens.forEach(token => {
88+
tokens.forEach(function(token, tokenIndex) {
8989
if (token.type === 'heading' && token.depth <= depth) {
9090
const { str, config } = getAndRemoveConfig(token.text);
9191

@@ -106,6 +106,15 @@ export function genIndex(path, content = '', router, depth) {
106106

107107
index[slug] = { slug, title: title, body: '' };
108108
} else {
109+
if (tokenIndex === 0) {
110+
slug = router.toURL(path);
111+
index[slug] = {
112+
slug,
113+
title: path !== '/' ? path.slice(1) : 'Home Page',
114+
body: token.text || '',
115+
};
116+
}
117+
109118
if (!slug) {
110119
return;
111120
}

0 commit comments

Comments
 (0)