Skip to content

Commit

Permalink
fix: cannot search list content (#1361)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Sep 3, 2020
1 parent 4807e58 commit 8d17dcb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugins/search/search.js
Expand Up @@ -66,6 +66,13 @@ function getTableData(token) {
return token.text;
}

function getListData(token) {
if (!token.text && token.type === 'list') {
token.text = token.raw;
}
return token.text;
}

function saveData(maxAge, expireKey, indexKey) {
localStorage.setItem(expireKey, Date.now() + maxAge);
localStorage.setItem(indexKey, JSON.stringify(INDEXS));
Expand Down Expand Up @@ -97,10 +104,12 @@ export function genIndex(path, content = '', router, depth) {
index[slug] = { slug, title: '', body: '' };
} else if (index[slug].body) {
token.text = getTableData(token);
token.text = getListData(token);

index[slug].body += '\n' + (token.text || '');
} else {
token.text = getTableData(token);
token.text = getListData(token);

index[slug].body = index[slug].body
? index[slug].body + token.text
Expand Down

1 comment on commit 8d17dcb

@vercel
Copy link

@vercel vercel bot commented on 8d17dcb Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.