Skip to content

Commit

Permalink
Merge pull request #1 from wkhearn/new-hp-modules
Browse files Browse the repository at this point in the history
New HP Clean Modules
  • Loading branch information
iamkevingreen authored Feb 14, 2020
2 parents 727d76e + 90b91f3 commit c11f923
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions api/wo/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = (parsed) => {
let icons = []
let links = []
let values = []
let singleRows = []
let highlights = []
let slides = []
let logos = []
let products = []
Expand Down Expand Up @@ -114,6 +116,28 @@ module.exports = (parsed) => {
})
cleanModules.push(cleanModule)
break;
case 'moduleMediumHero':
cleanModule = Object.assign({}, cleanModule, {
sys: {
contentType: {
sys: {
id: 'moduleMediumHero'
}
}
},
fields: {
image: {
fields: {
file: {
url: module.fields.image.fields.file.url
}
}
},
title: module.fields.title
}
})
cleanModules.push(cleanModule)
break;
case 'moduleCta':
let linkObject = null
if (module.fields.link) {
Expand Down Expand Up @@ -248,6 +272,84 @@ module.exports = (parsed) => {
})
cleanModules.push(cleanModule)
break;
case 'moduleVideoText':
module.fields.singleRow.forEach((row) => {
let cleanSingleRow = {
fields: {
imageFallback: {
fields: {
file: {
url: row.fields.imageFallback.fields.file.url
}
}
},
video: row.fields.video,
videoUrl: row.fields.videoUrl,
text: row.fields.text,
alignment: row.fields.alignment,
icon: {
fields: {
blueIcon: {
fields: {
file: {
url: row.fields.icon.fields.blueIcon.fields.file.url
}
}
}
}
}
}
}
singleRows.push(cleanSingleRow)
})
cleanModule = Object.assign({}, cleanModule, {
sys: {
contentType: {
sys: {
id: 'moduleVideoText'
}
}
},
fields: {
helpfulTitle: module.fields.helpfulTitle,
singleRow: singleRows
}
})
cleanModules.push(cleanModule)
break;
case 'moduleFeatureHighlights':
module.fields.featureHighlights.forEach((highlight) => {
let cleanHighlight = {
fields: {
image: {
fields: {
file: {
url: highlight.fields.image.fields.file.url
}
}
},
video: highlight.fields.video,
title: highlight.fields.title,
description: highlight.fields.description
}
}
highlights.push(cleanHighlight)
})
cleanModule = Object.assign({}, cleanModule, {
sys: {
contentType: {
sys: {
id: 'moduleFeatureHighlights'
}
}
},
fields: {
helpfulTitle: module.fields.helpfulTitle,
featureHighlights: highlights
}
})
cleanModules.push(cleanModule)
break;
case 'moduleSlideshow':
if (module.fields.companyLogo) {
module.fields.companyLogo.forEach((logo) => {
Expand Down

0 comments on commit c11f923

Please sign in to comment.