Skip to content

Commit

Permalink
fix(gatsby-transformer-remark): don't convert Date objects (#10924)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst authored and pieh committed Jan 25, 2019
1 parent 79bc7d4 commit 4463f52
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions packages/gatsby-transformer-remark/src/on-node-create.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const grayMatter = require(`gray-matter`)
const crypto = require(`crypto`)
const _ = require(`lodash`)

module.exports = async function onCreateNode(
{ node, loadNodeContent, actions, createNodeId, reporter },
Expand All @@ -19,18 +18,7 @@ module.exports = async function onCreateNode(
const content = await loadNodeContent(node)

try {
let data = grayMatter(content, pluginOptions)
// Convert date objects to string. Otherwise there's type mismatches
// during inference as some dates are strings and others date objects.
if (data.data) {
data.data = _.mapValues(data.data, v => {
if (_.isDate(v)) {
return v.toJSON()
} else {
return v
}
})
}
const data = grayMatter(content, pluginOptions)

const markdownNode = {
id: createNodeId(`${node.id} >>> MarkdownRemark`),
Expand Down

0 comments on commit 4463f52

Please sign in to comment.