From 2915daade0e8eb5ab2e140190f357a6bfc8eef87 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Tue, 7 Nov 2017 15:55:03 +0100 Subject: [PATCH] Fix publish date on blog posts --- src/utils/compiler.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/compiler.js b/src/utils/compiler.js index 6e051b5..86f41c0 100644 --- a/src/utils/compiler.js +++ b/src/utils/compiler.js @@ -28,11 +28,19 @@ function fileMetadata(filepath) { function compile(filepath, data, fileData, callback) { const frontMatter = fm(fileData); + console.log(frontMatter); const rendered = render(frontMatter.body); const metadata = fileMetadata(filepath); + let published; + if (frontMatter.attributes.date) { + published = moment(frontMatter.attributes.date); + } else { + published = moment(); + } + const post = { - published: moment().format('MMMM Do YYYY'), + published: published.format('MMMM Do YYYY'), filename: metadata.filename, title: frontMatter.attributes.title, summary: frontMatter.attributes.summary,