You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ozgurkon-site/tools/generate-speakers.js

29 lines
708 B

6 years ago
const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
const writeOption = {
flag: 'w'
};
6 years ago
const firebaseData = require('./firebase-data.json');
6 years ago
const generateSpeakerData = (id, speaker) => {
6 years ago
const frontMatter = {id, ...speaker};
delete frontMatter.bio;
6 years ago
return `---
${yaml.safeDump(frontMatter, {skipInvalid: true})}
---
6 years ago
${speaker.bio}
6 years ago
`;
};
Object.entries(firebaseData.speakers)
.map(([id, speaker]) => ([id, generateSpeakerData(id, speaker)]))
.forEach(([id, data]) => {
6 years ago
const dest = path.join(__dirname, `../content/speakers/${id}.md`);
6 years ago
console.log('Write to', dest);
fs.writeFileSync(dest, data, writeOption);
});