const fs = require('fs'); const path = require('path'); const tags = [ { id: 'personal', title: 'Personal 👨' } ] const posts = [ { url: "_posts/hello_world.html", title: "Hello, World!", tags: [ "personal" ] } ]; function createTag(tag) { return ` `; } function createPostServableFile(post) { const dir = path.resolve(path.join(__dirname, '..', 'posts')); if (!fs.existsSync(dir)) { fs.mkdirSync(dir); } const baseFilePath = path.join(__dirname, '..', post.url); const stats = fs.statSync(baseFilePath); const content = fs.readFileSync(baseFilePath); const fileName = post.url.substring(post.url.lastIndexOf('/')); const filePath = path.join(dir, fileName); fs.writeFileSync(filePath,` Matthew Kosarek

Matthew Kosarek

${post.title}

Created ${stats.birthtime.toLocaleString()}. Last updated: ${stats.mtime.toLocaleString()}

${content}
`) return '/posts/' + fileName; } function createPostLink(post) { return `
  • ${post.title}
  • `; } const output = ` Matthew Kosarek

    Matthew Kosarek

    Tags

    ${tags.map(createTag)}

    Posts

    ` fs.writeFileSync(path.join(__dirname, '..', 'posts.html'), output);