gatsby-node-helpers
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "gatsby-node-helpers", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Gatsby node helper functions to aid node creation.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -29,2 +29,4 @@ # gatsby-node-helpers | ||
Call `createNodeHelpers` with options. | ||
```js | ||
@@ -44,2 +46,4 @@ import createNodeHelpers from 'gatsby-node-helpers' | ||
Call `createNodeFactory` with a type name. | ||
```js | ||
@@ -56,3 +60,3 @@ import createNodeHelpers from 'gatsby-node-helpers' | ||
export const DocumentNode = createNodeFactory('DocumentNode') | ||
export const ProductNode = createNodeFactory(`Product`) | ||
``` | ||
@@ -62,17 +66,21 @@ | ||
`ProductNode` accepts an object and returns a new object to be passed to | ||
Gatsby's `createNode` action creator. | ||
It handles setting up Gatsby's internal fields, including the content digest | ||
and node type. | ||
```js | ||
// gatsby-node.js | ||
import { DocumentNode } from './nodes' | ||
import { getAllDocuments } from './api' | ||
import { ProductNode } from './nodes' | ||
import { getAllProducts } from './api' | ||
const documents = getAllDocuments() | ||
exports.sourceNodes = async ({ boundActionCreators }) => { | ||
const { createNode } = boundActionCreators | ||
const documents = await getAllDocuments() | ||
const products = await getAllProducts() | ||
documents.forEach(document => { | ||
const node = DocumentNode(document) | ||
products.forEach(product => { | ||
const node = ProductNode(product) | ||
createNode(node) | ||
@@ -86,1 +94,3 @@ }) | ||
Coming soon... | ||
[gatsby-source-plugins]: https://www.gatsbyjs.org/docs/create-source-plugin/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7139
6
92