mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-14 17:15:18 +01:00
date fixes
This commit is contained in:
parent
a6affd683f
commit
7206eca86c
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user