Skip to content

Commit 1b9710a

Browse files
author
Willy Hardy
committed
use map and join instead of foreach
1 parent d75405f commit 1b9710a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/plugins/search/search.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ export function genIndex(path, content = '', router, depth) {
6969
} else if (index[slug].body) {
7070
index[slug].body += '\n' + (token.text || '')
7171
} else if (token.type === 'table'){
72-
var tableString = '|';
73-
token.cells.forEach(function (rows) {
74-
rows.forEach(function(cell) {
75-
tableString += ' ' + cell + ' |';
76-
});
77-
});
72+
var tableString = token.cells.map(function (rows) {
73+
return rows.join(' | ');
74+
}).join(' |\n ');
7875
index[slug].body = tableString;
7976
} else {
8077
index[slug].body = token.text

0 commit comments

Comments
 (0)