Özgür kon site forku
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
718 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]) => {
const dest = path.join(__dirname, `../test-hugo/content/speakers/${id}.md`);
console.log('Write to', dest);
fs.writeFileSync(dest, data, writeOption);
});