'use strict';
const fs = require('fs-extra');
const marked = require('marked');
const parser = require('./littlePostParser');

module.exports = function readFiles(path) {
  const posts = [];
  fs.ensureDirSync(path);
  fs.readdirSync(path).forEach(file => {
    let date = file.match(/^(\d{4})-(\d\d?)-(\d\d?)-(.+)\.(md|markdown|html)$/);
    if (!date)
      return;
    const post = parser(path + '/' + file);
    const name = date[4];
    const Post = Object.assign(post, { main: marked(post.main), name: name });
    posts.push(Post);
  });
  return posts;
};

@@ -346,16 +346,18 @@
  (!date)
+ %7B
 %0A      r
@@ -363,16 +363,71 @@
 return;%0A
+    %7D%0A    const d = %60$%7Bdate%5B3%5D%7D.$%7Bdate%5B2%5D%7D.$%7Bdate%5B1%5D%7D%60%0A
     cons
@@ -562,16 +562,25 @@
 me: name
+, date: d
  %7D);%0A   

Add `date` to post meta-date-uh 😆