Because the post Gatsby descrete notes is too long, I write a separate post just for images in Gatsby.
import
and use img
.svg
cannot be used with childImageSharp
, just use <img>
with its publicURL
.png
, jpg
can be used with <Img>
and childImageSharp
.json
or yaml
, cannot use js
for images.edges
. After edges
, there are a loop of node
s.query
components must placed in <StaticQuery />
.fixed
.fluid
.query
.{condition && condition && output}
instead of using if..else...
Read this post from CSS-Tricks to know which images should be processed, which ones should not.
import
and use <img>
to directly import them.Install stuffs following this doc,
npm install --save gatsby-image gatsby-plugin-sharp gatsby-transformer-sharp