@@ -54,6 +54,17 @@ function getAllPaths(router) {
54
54
return paths ;
55
55
}
56
56
57
+ function getTableData ( token ) {
58
+ if ( ! token . text && token . type === 'table' ) {
59
+ token . text = token . cells
60
+ . map ( function ( rows ) {
61
+ return rows . join ( ' | ' ) ;
62
+ } )
63
+ . join ( ' |\n ' ) ;
64
+ }
65
+ return token . text ;
66
+ }
67
+
57
68
function saveData ( maxAge , expireKey , indexKey ) {
58
69
localStorage . setItem ( expireKey , Date . now ( ) + maxAge ) ;
59
70
localStorage . setItem ( indexKey , JSON . stringify ( INDEXS ) ) ;
@@ -84,23 +95,11 @@ export function genIndex(path, content = '', router, depth) {
84
95
if ( ! index [ slug ] ) {
85
96
index [ slug ] = { slug, title : '' , body : '' } ;
86
97
} else if ( index [ slug ] . body ) {
87
- if ( ! token . text && token . type === 'table' ) {
88
- token . text = token . cells
89
- . map ( function ( rows ) {
90
- return rows . join ( ' | ' ) ;
91
- } )
92
- . join ( ' |\n ' ) ;
93
- }
98
+ token . text = getTableData ( token ) ;
94
99
95
100
index [ slug ] . body += '\n' + ( token . text || '' ) ;
96
101
} else {
97
- if ( ! token . text && token . type === 'table' ) {
98
- token . text = token . cells
99
- . map ( function ( rows ) {
100
- return rows . join ( ' | ' ) ;
101
- } )
102
- . join ( ' |\n ' ) ;
103
- }
102
+ token . text = getTableData ( token ) ;
104
103
105
104
index [ slug ] . body = index [ slug ] . body
106
105
? index [ slug ] . body + token . text
0 commit comments