1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-14 09:05:17 +01:00

date fixes

This commit is contained in:
Matthias Kretschmann 2019-02-03 21:18:59 +01:00
parent a6affd683f
commit 7206eca86c
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 4 additions and 7 deletions

View File

@ -27,15 +27,13 @@ exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(`
{
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) {
allMarkdownRemark {
edges {
node {
fields {
slug
date
}
frontmatter {
type
tags
}
}

View File

@ -24,12 +24,11 @@ exports.createMarkdownFields = (node, createNodeField, getNode) => {
})
// date
let date
// grab date from file path
let date = new Date(slugOriginal.substring(1, 11)).toISOString() // grab date from file path
if (node.frontmatter.date) {
date = `${node.frontmatter.date}`
} else {
date = `${slugOriginal.substring(1, 10)}` // grab date from file path
date = new Date(node.frontmatter.date).toISOString()
}
createNodeField({