Merge pull request #159 from timlrx/fix/date
fix: support date type in blog frontmatter
This commit is contained in:
commit
47c8a819cf
@ -1,7 +1,7 @@
|
||||
---
|
||||
title: 'Introducing Tailwind Nexjs Starter Blog'
|
||||
title: 'Introducing Tailwind Nextjs Starter Blog'
|
||||
date: '2021-01-12'
|
||||
lastmod: '2021-07-28'
|
||||
lastmod: '2021-08-02'
|
||||
tags: ['next-js', 'tailwind', 'guide']
|
||||
draft: false
|
||||
summary: 'Looking for a performant, out of the box template, with all the best in web technology to support your blogging needs? Checkout the Tailwind Nextjs Starter Blog template.'
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: 'New features in v1'
|
||||
date: '2021-07-28'
|
||||
date: 2021-07-28T15:32:14Z
|
||||
tags: ['next-js', 'tailwind', 'guide']
|
||||
draft: false
|
||||
summary: 'An overview of the new features released in v1 - code block copy, multiple authors, frontmatter layout and more'
|
||||
|
11
lib/mdx.js
11
lib/mdx.js
@ -116,6 +116,7 @@ export async function getFileBySlug(type, slug) {
|
||||
slug: slug || null,
|
||||
fileName: fs.existsSync(mdxPath) ? `${slug}.mdx` : `${slug}.md`,
|
||||
...frontmatter,
|
||||
date: frontmatter.date ? new Date(frontmatter.date).toISOString() : null,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -135,9 +136,13 @@ export async function getAllFilesFrontMatter(folder) {
|
||||
return
|
||||
}
|
||||
const source = fs.readFileSync(file, 'utf8')
|
||||
const { data } = matter(source)
|
||||
if (data.draft !== true) {
|
||||
allFrontMatter.push({ ...data, slug: formatSlug(fileName) })
|
||||
const { data: frontmatter } = matter(source)
|
||||
if (frontmatter.draft !== true) {
|
||||
allFrontMatter.push({
|
||||
...frontmatter,
|
||||
slug: formatSlug(fileName),
|
||||
date: frontmatter.date ? new Date(frontmatter.date).toISOString() : null,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user