-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbuild-list.js
More file actions
29 lines (26 loc) · 854 Bytes
/
build-list.js
File metadata and controls
29 lines (26 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const fs = require('fs');
const episodes = require('./content/episodes.json');
const obj = [];
// loop through the episode list and construct a new object
for(let ep in episodes) {
const episode = episodes[ep].episode;
const title = episodes[ep].title;
const description = episodes[ep].description;
const published = episodes[ep].published;
if(episode !== undefined) {
// only use keys from the original JSON needed
const details = {
episode: episode,
title: title,
description: description,
published: published
};
// add details to object
obj.push(details);
}
}
// create episode-list JSON file
fs.writeFile('./content/episode-list.json', JSON.stringify(obj), function (err) {
return err ? console.log(err) : null;
});