File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -157,31 +157,29 @@ function compileToHTML(json) {
157
157
158
158
function parseContent ( item ) {
159
159
const result = [ ]
160
+ iterateContent ( item , result , [ ] )
161
+ return result
162
+ }
160
163
164
+ function iterateContent ( item , result , types ) {
161
165
item . content . forEach ( it => {
162
166
if ( typeof it === 'string' ) {
163
167
result . push ( {
164
- types : [ item . type ] ,
168
+ types : removeDuplicates ( types . concat ( [ item . type ] ) ) ,
165
169
value : it
166
170
} )
167
171
} else {
168
- it . content . forEach ( i => {
169
- if ( typeof i === 'string' ) {
170
- result . push ( {
171
- types : [ it . type ] . concat ( [ item . type ] ) ,
172
- value : i
173
- } )
174
- } else {
175
- result . push ( {
176
- types : [ i . type ] . concat ( [ it . type ] ) . concat ( [ item . type ] ) ,
177
- value : parseContent ( i )
178
- } )
179
- }
180
- } )
172
+ iterateContent (
173
+ it ,
174
+ result ,
175
+ removeDuplicates ( [ it . type ] . concat ( [ item . type ] ) . concat ( types ) )
176
+ )
181
177
}
182
178
} )
179
+ }
183
180
184
- return result
181
+ function removeDuplicates ( items ) {
182
+ return [ ...new Set ( items ) ]
185
183
}
186
184
187
185
function linkifyResult ( array ) {
You can’t perform that action at this time.
0 commit comments