Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Created November 15, 2018 15:11
Show Gist options
  • Select an option

  • Save DominikAngerer/9a781b3defbbc5ca05ea95da33be68a8 to your computer and use it in GitHub Desktop.

Select an option

Save DominikAngerer/9a781b3defbbc5ca05ea95da33be68a8 to your computer and use it in GitHub Desktop.
migration.js
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