Fix publish date on blog posts

This commit is contained in:
LordMathis 2017-11-07 15:55:03 +01:00
parent 4048fbbc66
commit 2915daade0
1 changed files with 9 additions and 1 deletions

View File

@ -28,11 +28,19 @@ function fileMetadata(filepath) {
function compile(filepath, data, fileData, callback) { function compile(filepath, data, fileData, callback) {
const frontMatter = fm(fileData); const frontMatter = fm(fileData);
console.log(frontMatter);
const rendered = render(frontMatter.body); const rendered = render(frontMatter.body);
const metadata = fileMetadata(filepath); const metadata = fileMetadata(filepath);
let published;
if (frontMatter.attributes.date) {
published = moment(frontMatter.attributes.date);
} else {
published = moment();
}
const post = { const post = {
published: moment().format('MMMM Do YYYY'), published: published.format('MMMM Do YYYY'),
filename: metadata.filename, filename: metadata.filename,
title: frontMatter.attributes.title, title: frontMatter.attributes.title,
summary: frontMatter.attributes.summary, summary: frontMatter.attributes.summary,