Ö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

const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
const writeOption = {
flag: 'w'
};
const firebaseData = require('./firebase-data.json');
const generateSpeakerData = (id, speaker) => {
const frontMatter = {id, ...speaker};
delete frontMatter.bio;
return `---
${yaml.safeDump(frontMatter, {skipInvalid: true})}
---
${speaker.bio}
`;
};
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);
});