Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ function getAllPaths(router) {
return paths;
}

function getTableData(token) {
if (!token.text && token.type === 'table') {
token.text = token.cells
.map(function(rows) {
return rows.join(' | ');
})
.join(' |\n ');
}
return token.text;
}

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

index[slug].body += '\n' + (token.text || '');
} else {
if (!token.text) {
if (token.type === 'table') {
token.text = token.cells
.map(function(rows) {
return rows.join(' | ');
})
.join(' |\n ');
}
}
token.text = getTableData(token);

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