Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example to the sourceNodes docs #8585

Merged
merged 4 commits into from
Sep 27, 2018
Merged

Conversation

m-allanson
Copy link
Contributor

@m-allanson m-allanson commented Sep 27, 2018

Add usable example code to the sourceNodes API docs. The aim is to show the essentials of sourcing / creating a node without trying to do anything fancy or clever.

Refs: https://twitter.com/xjamundx/status/1045036899646111744?s=19

Thanks @octalmage for linking to https://github.com/jamesdanylik/gatsby-source-git-commit/blob/master/gatsby-node.js, I adapted my first version based on some of the ideas in there. Thanks @LekoArts for the review in Discord :)

@m-allanson m-allanson requested a review from a team as a code owner September 27, 2018 11:57
Copy link
Contributor

@DSchau DSchau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

* }
*
* const nodeContent = JSON.stringify(myData)
* const nodeContentDigest = crypto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but I think you mentioned it too... we use this algorithm all over the place, so it's probably worth passing that to various APIs or something, e.g.

const createContentDigest = obj => crypto
  .createHash(`md5`)
  .update(obj)
  .digest(`hex`)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 to that, here's an issue #8587

@m-allanson m-allanson merged commit bab08df into master Sep 27, 2018
@m-allanson m-allanson deleted the docs-source-nodes-example branch September 27, 2018 14:58
lipis added a commit to lipis/gatsby that referenced this pull request Sep 27, 2018
* 'master' of github.com:gatsbyjs/gatsby:
  Add blog post on v2 reach router (gatsbyjs#8508)
  feat: add self to community page (gatsbyjs#8572)
  feat: update sites.yml (gatsbyjs#8589)
  Add an example to the sourceNodes docs (gatsbyjs#8585)
  chore(release): Publish
  fix: add compat fix for gatsby-cli v2 with gatsby v1 (gatsbyjs#8581)
  fix: fix unhandled rejection when no browser found when running with --open flag (gatsbyjs#8507)
  Fix writing out new page information (so new pages hot reload) during development (gatsbyjs#8570)
  Run coverage at the end of jest and configure thresholds (gatsbyjs#8371)
  chore(release): Publish
  chore: update gatsby-source-drupal version in using-drupal example (gatsbyjs#8497)
  Typo fix in gatsby-source-graphql/README.md (gatsbyjs#8562)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants