Skip to content

Commit 625b141

Browse files
authored
chore(docs): Update outdated building a theme tutorial snippets (#35792)
Fixing #35784 Signed-off-by: Josh Cox <[email protected]>
1 parent 160bbf0 commit 625b141

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/tutorial/building-a-theme.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ You should now see the following dependencies in your `site/package.json`:
100100
```json:title=site/package.json
101101
{
102102
"dependencies": {
103-
"gatsby": "^3.0.0",
103+
"gatsby": "^4.15.1",
104104
"gatsby-theme-events": "*",
105-
"react": "^17.0.0",
106-
"react-dom": "^17.0.0"
105+
"react": "^18.1.0",
106+
"react-dom": "^18.1.0"
107107
}
108108
}
109109
```
@@ -142,9 +142,9 @@ The `gatsby-theme-events/package.json` file should now include the following:
142142
```json:title=gatsby-theme-events/package.json
143143
{
144144
"peerDependencies": {
145-
"gatsby": "^3.0.0",
146-
"react": "^17.0.0",
147-
"react-dom": "^17.0.0"
145+
"gatsby": "^4.15.1",
146+
"react": "^18.1.0",
147+
"react-dom": "^18.1.0"
148148
}
149149
}
150150
```
@@ -224,7 +224,7 @@ module.exports = {
224224
{
225225
resolve: "gatsby-source-filesystem",
226226
options: {
227-
path: "data",
227+
path: `${__dirname}/data/`,
228228
},
229229
},
230230
{
@@ -272,7 +272,7 @@ const fs = require("fs")
272272

273273
// Make sure the data directory exists
274274
exports.onPreBootstrap = ({ reporter }) => {
275-
const contentPath = "data"
275+
const contentPath = `${__dirname}/data/`
276276

277277
if (!fs.existsSync(contentPath)) {
278278
reporter.info(`creating the ${contentPath} directory`)
@@ -296,7 +296,7 @@ const fs = require("fs")
296296

297297
// Make sure the data directory exists
298298
exports.onPreBootstrap = ({ reporter }) => {
299-
const contentPath = "data"
299+
const contentPath = `${__dirname}/data/`
300300

301301
if (!fs.existsSync(contentPath)) {
302302
reporter.info(`creating the ${contentPath} directory`)
@@ -337,7 +337,7 @@ const fs = require("fs")
337337

338338
// Make sure the data directory exists
339339
exports.onPreBootstrap = ({ reporter }) => {
340-
const contentPath = "data"
340+
const contentPath = `${__dirname}/data/`
341341

342342
if (!fs.existsSync(contentPath)) {
343343
reporter.info(`creating the ${contentPath} directory`)
@@ -985,7 +985,7 @@ Update the `gatsby-theme-events/gatsby-config.js` to accept options:
985985

986986
```javascript:title=gatsby-theme-events/gatsby-config.js
987987
// highlight-next-line
988-
module.exports = ({ contentPath = "data", basePath = "/" }) => ({
988+
module.exports = ({ contentPath = `${__dirname}/data/`, basePath = "/" }) => ({
989989
plugins: [
990990
{
991991
resolve: "gatsby-source-filesystem",
@@ -1004,7 +1004,7 @@ module.exports = ({ contentPath = "data", basePath = "/" }) => ({
10041004
})
10051005
```
10061006

1007-
The `contentPath` will default to "data", and the `basePath` will default to the root, "/".
1007+
The `contentPath` will default to `${__dirname}/data/`, and the `basePath` will default to the root, "/".
10081008

10091009
In `gatsby-node.js`, the options that were added to the `gatsby-config.js` function are provided as a second argument to Gatsby's API hooks.
10101010

@@ -1013,7 +1013,7 @@ Update the `contentPath` to use the option set in `gatsby-config.js`:
10131013
```javascript:title=gatsby-theme-events/gatsby-node.js
10141014
// highlight-start
10151015
exports.onPreBootstrap = ({ reporter }, options) => {
1016-
const contentPath = options.contentPath || "data"
1016+
const contentPath = options.contentPath || `${__dirname}/data/`
10171017
// highlight-end
10181018

10191019
// {...}
@@ -1097,7 +1097,7 @@ yarn workspace gatsby-theme-events add gatsby-plugin-theme-ui theme-ui
10971097
Then, add the `gatsby-plugin-theme-ui` plugin to the `gatsby-theme-events/gatsby-config.js` file:
10981098

10991099
```javascript:title=gatsby-theme-events/gatsby-config.js
1100-
module.exports = ({ contentPath = "data", basePath = "/" }) => ({
1100+
module.exports = ({ contentPath = `${__dirname}/data/`, basePath = "/" }) => ({
11011101
plugins: [
11021102
// highlight-next-line
11031103
"gatsby-plugin-theme-ui",

0 commit comments

Comments
 (0)