Skip to content

Commit

Permalink
refactor(gatsby): update internal-data-bridge plugin to use createCon…
Browse files Browse the repository at this point in the history
…tentDigest (gatsbyjs#10471)
  • Loading branch information
smurrayatwork authored and gpetrioli committed Jan 22, 2019
1 parent af1ff5f commit b20c095
Showing 1 changed file with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const crypto = require(`crypto`)
const moment = require(`moment`)
const chokidar = require(`chokidar`)
const systemPath = require(`path`)
Expand Down Expand Up @@ -42,7 +41,7 @@ function transformPackageJson(json) {

const createPageId = path => `SitePage ${path}`

exports.sourceNodes = ({ actions, store }) => {
exports.sourceNodes = ({ createContentDigest, actions, store }) => {
const { createNode } = actions
const state = store.getState()
const { program } = state
Expand All @@ -58,10 +57,7 @@ exports.sourceNodes = ({ actions, store }) => {
children: [],
internal: {
type: `SitePage`,
contentDigest: crypto
.createHash(`md5`)
.update(JSON.stringify(page))
.digest(`hex`),
contentDigest: createContentDigest(page),
},
})

Expand All @@ -75,10 +71,7 @@ exports.sourceNodes = ({ actions, store }) => {
parent: `SOURCE`,
children: [],
internal: {
contentDigest: crypto
.createHash(`md5`)
.update(JSON.stringify(plugin))
.digest(`hex`),
contentDigest: createContentDigest(plugin),
type: `SitePlugin`,
},
})
Expand Down Expand Up @@ -108,10 +101,7 @@ exports.sourceNodes = ({ actions, store }) => {
parent: `SOURCE`,
children: [],
internal: {
contentDigest: crypto
.createHash(`md5`)
.update(JSON.stringify(node))
.digest(`hex`),
contentDigest: createContentDigest(node),
type: `Site`,
},
})
Expand Down Expand Up @@ -139,7 +129,7 @@ exports.sourceNodes = ({ actions, store }) => {
})
}

exports.onCreatePage = ({ page, actions }) => {
exports.onCreatePage = ({ createContentDigest, page, actions }) => {
const { createNode } = actions
// eslint-disable-next-line
const { updatedAt, ...pageWithoutUpdated } = page
Expand All @@ -152,10 +142,7 @@ exports.onCreatePage = ({ page, actions }) => {
children: [],
internal: {
type: `SitePage`,
contentDigest: crypto
.createHash(`md5`)
.update(JSON.stringify(pageWithoutUpdated))
.digest(`hex`),
contentDigest: createContentDigest(pageWithoutUpdated),
description:
page.pluginCreatorId === `Plugin default-site-plugin`
? `Your site's "gatsby-node.js"`
Expand Down

0 comments on commit b20c095

Please sign in to comment.