File tree 1 file changed +27
-5
lines changed
1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -431,12 +431,34 @@ export interface GatsbyNode<
431
431
* transform nodes created by other plugins should implement this API.
432
432
*
433
433
* See also the documentation for `createNode`
434
- * and [`createNodeField`](https://www.gatsbyjs.com/docs/actions/#createNodeField)
434
+ * and [`createNodeField`](https://www.gatsbyjs.com/docs/reference/config-files/actions/#createNodeField)
435
+ * @param {object } $0
436
+ * @param {object } $0.node A node object.
437
+ * @param {object } $0.actions
438
+ * @param {function } $0.actions.createNode Create a new node.
439
+ * @param {function } $0.actions.createNodeField Extend another node. The new node field is placed under the fields key on the extended node object.
435
440
* @example
436
- * exports.onCreateNode = ({ node, actions }) => {
437
- * const { createNode, createNodeField } = actions
438
- * // Transform the new node here and create a new node or
439
- * // create a new node field.
441
+ * exports.onCreateNode = ({ node, getNode, actions }) => {
442
+ * const { createNodeField } = actions
443
+ *
444
+ * if (node.internal.type === `MarkdownRemark`) {
445
+ * const nodePath = node.fileAbsolutePath
446
+ *
447
+ * if (nodePath.match(/\/blog\//)) {
448
+ * const postSlug = createFilePath({
449
+ * node,
450
+ * getNode,
451
+ * basePath: `src/content`,
452
+ * trailingSlash: true,
453
+ * })
454
+ *
455
+ * createNodeField({
456
+ * node,
457
+ * name: `slug`,
458
+ * value: `/blog/${postSlug}/`,
459
+ * })
460
+ * }
461
+ * }
440
462
* }
441
463
*/
442
464
onCreateNode ?(
You can’t perform that action at this time.
0 commit comments