-
-
Save duyenho/5f984cdb8dae599aebd20f4be3870740 to your computer and use it in GitHub Desktop.
This file contains 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
// For each image in the dataset, output this object: | |
// { src: "picture-3.jpg", caption: "Lorem Ipsum Dolor 2<br>Ut enim ad minim veniam, quis nostrud exercitation ullamco<br>2017" } | |
const data = [ | |
{ | |
"title": "Lorem Ipsum Dolor 1", | |
"description": "Ut enim ad minim veniam, quis nostrud exercitation ullamco.", | |
"year": "2018", | |
"images": [ | |
"picture-1.jpg", | |
"picture-2.jpg" | |
] | |
}, | |
{ | |
"title": "Lorem Ipsum Dolor 2", | |
"description": "Ut enim ad minim veniam, quis nostrud exercitation ullamco", | |
"year": "2017", | |
"images": ["picture-3.jpg"] | |
}, | |
] | |
const works = [] | |
data.forEach(work => { | |
works.push(work.images.map(image => { | |
return { | |
"src": image, | |
"caption": `${work.title}<br>${work.description}<br>${work.year}` | |
} | |
})) | |
}); | |
const flattenedWorks = [].concat.apply([], works); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment