Based on a Premium JavaScript + CSS Training Course from Wes Bos. You can grab the course at MasterGatsby.com.
- Gatsby by default uses
module.exports = {
commonJS syntax node typically in the gatsby documentation and we want to use ES6 modulesexport default {
. So that we can use es modules this project we use a package called esm. - to enable within thepackage.json
we can addNODE_OPTIONS="-r esm"
in front ofgatsby build
. The cross-env package is there for windows users. - Page Queries (ie Dynamic) / Static Queries - Query outside of a page - ie ina function queries that do not take variables (gatsby limitation)
- To expose environments variable to the front end of your gatsby build they need to be prefixed with
GATSBY_
- Nested chaining example to check for Items -
{pizza.image?.asset?.fluid?.src}
example ingatsby/src/templates/Pizza.js
- Check out the project
- From within
gatsby
runnpm run start
- from within
sanity
runnpm run start