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) {
157157
158158function parseContent ( item ) {
159159 const result = [ ]
160+ iterateContent ( item , result , [ ] )
161+ return result
162+ }
160163
164+ function iterateContent ( item , result , types ) {
161165 item . content . forEach ( it => {
162166 if ( typeof it === 'string' ) {
163167 result . push ( {
164- types : [ item . type ] ,
168+ types : removeDuplicates ( types . concat ( [ item . type ] ) ) ,
165169 value : it
166170 } )
167171 } 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+ )
181177 }
182178 } )
179+ }
183180
184- return result
181+ function removeDuplicates ( items ) {
182+ return [ ...new Set ( items ) ]
185183}
186184
187185function linkifyResult ( array ) {
You can’t perform that action at this time.
0 commit comments