From b5f0252e118eb7b8388f71b39c68f6671af138b5 Mon Sep 17 00:00:00 2001 From: Stephan Weinhold Date: Fri, 6 Nov 2020 19:35:06 +0100 Subject: [PATCH 1/2] Added require("path") to the example to avoid confusion. --- docs/docs/creating-and-modifying-pages.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/creating-and-modifying-pages.md b/docs/docs/creating-and-modifying-pages.md index ed694a042cd7b..a5d240b855893 100644 --- a/docs/docs/creating-and-modifying-pages.md +++ b/docs/docs/creating-and-modifying-pages.md @@ -121,6 +121,7 @@ Using the `id` as an access point to query for other properties in the template ```javascript:title=gatsby-node.js +const pathObject = require("path"); exports.createPages = async ({ graphql, actions }) => { const { createPage } = actions; const queryResults = await graphql(` From 603dd008b454685578efdb38a88a07af26e4e576 Mon Sep 17 00:00:00 2001 From: Lennart Date: Mon, 9 Nov 2020 14:32:28 +0100 Subject: [PATCH 2/2] update imports --- docs/docs/creating-and-modifying-pages.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/docs/creating-and-modifying-pages.md b/docs/docs/creating-and-modifying-pages.md index a5d240b855893..ca71ddfc5fe13 100644 --- a/docs/docs/creating-and-modifying-pages.md +++ b/docs/docs/creating-and-modifying-pages.md @@ -54,6 +54,8 @@ This example assumes that each markdown page has a `path` set in the frontmatter of the markdown file. ```javascript:title=gatsby-node.js +const path = require("path") + // Implement the Gatsby API “createPages”. This is called once the // data layer is bootstrapped to let plugins create pages from data. exports.createPages = async ({ graphql, actions, reporter }) => { @@ -120,8 +122,8 @@ In the initial approach you have seen how the `gatsby-node.js` file would have a Using the `id` as an access point to query for other properties in the template is the default approach. However, suppose you had a list of products with properties you would like to query for. Handling the query entirely from `gatsby-node.js` would result in the query looking like this: ```javascript:title=gatsby-node.js +const path = require("path") -const pathObject = require("path"); exports.createPages = async ({ graphql, actions }) => { const { createPage } = actions; const queryResults = await graphql(`