Created
November 15, 2018 15:11
-
-
Save DominikAngerer/9a781b3defbbc5ca05ea95da33be68a8 to your computer and use it in GitHub Desktop.
migration.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let story = ''; | |
| const resolve = (item) => { | |
| if (typeof item.component !== 'undefined' && item.component == 'markdown') { | |
| if (typeof item.margin_top === 'undefined' || item.margin_top == '') { | |
| item.margin_top = 'no-margin-top' | |
| } | |
| if (typeof item.margin_bottom === 'undefined' || item.margin_bottom == '') { | |
| item.margin_bottom = 'no-margin-bottom' | |
| } | |
| if (typeof item.text_alignment === 'undefined' || item.text_alignment == '') { | |
| item.text_alignment = 'has-text-left' | |
| } | |
| } | |
| for (let property in item) { | |
| if (item.hasOwnProperty(property)) { | |
| if (typeof Array.isArray(item[property])) { | |
| for (let index = 0; index < item[property].length; index++) { | |
| resolve(item[property][index]) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| for (let index = 0; index < story.story.content.body.length; index++) { | |
| const element = story.story.content.body[index]; | |
| resolve(element) | |
| } | |
| console.log(JSON.stringify(story)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment