1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-15 01:25:28 +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(` const result = await graphql(`
{ {
allMarkdownRemark(sort: { fields: [fields___date], order: DESC }) { allMarkdownRemark {
edges { edges {
node { node {
fields { fields {
slug slug
date
} }
frontmatter { frontmatter {
type
tags tags
} }
} }

View File

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