Skip to content

Commit c84d6d6

Browse files
committed
migrate example to gatsby 3
1 parent 300fa4c commit c84d6d6

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "Dmitriy Nevzorov <dmitriy.nevzorov@microapps.com>",
77
"dependencies": {
88
"gatsby": "^3.1.0",
9-
"gatsby-image": "^3.1.0",
9+
"gatsby-plugin-image": "^1.1.1",
1010
"gatsby-plugin-manifest": "^3.1.0",
1111
"gatsby-plugin-offline": "^4.1.0",
1212
"gatsby-plugin-react-helmet": "^4.1.0",

example/src/components/image.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,19 @@
11
import React from 'react';
22
import {useStaticQuery, graphql} from 'gatsby';
3-
import Img from 'gatsby-image';
4-
5-
/*
6-
* This component is built using `gatsby-image` to automatically serve optimized
7-
* images with lazy loading and reduced file sizes. The image is loaded using a
8-
* `useStaticQuery`, which allows us to load the image from directly within this
9-
* component, rather than having to pass the image data down from pages.
10-
*
11-
* For more information, see the docs:
12-
* - `gatsby-image`: https://gatsby.dev/gatsby-image
13-
* - `useStaticQuery`: https://www.gatsbyjs.org/docs/use-static-query/
14-
*/
3+
import {GatsbyImage} from 'gatsby-plugin-image';
154

165
const Image = () => {
176
const data = useStaticQuery(graphql`
187
query {
198
placeholderImage: file(relativePath: {eq: "gatsby-astronaut.png"}) {
209
childImageSharp {
21-
fluid(maxWidth: 300) {
22-
...GatsbyImageSharpFluid
23-
}
10+
gatsbyImageData(layout: FIXED, width: 300)
2411
}
2512
}
2613
}
2714
`);
2815

29-
return <Img fluid={data.placeholderImage.childImageSharp.fluid} />;
16+
return <GatsbyImage image={data.placeholderImage.childImageSharp.gatsbyImageData} />;
3017
};
3118

3219
export default Image;

example/yarn.lock

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,6 +2730,11 @@ babel-extract-comments@^1.0.0:
27302730
dependencies:
27312731
babylon "^6.18.0"
27322732

2733+
babel-jsx-utils@^1.1.0:
2734+
version "1.1.0"
2735+
resolved "https://registry.yarnpkg.com/babel-jsx-utils/-/babel-jsx-utils-1.1.0.tgz#304ce4fce0c86cbeee849551a45eb4ed1036381a"
2736+
integrity sha512-Mh1j/rw4xM9T3YICkw22aBQ78FhsHdsmlb9NEk4uVAFBOg+Ez9ZgXXHugoBPCZui3XLomk/7/JBBH4daJqTkQQ==
2737+
27332738
babel-loader@^8.2.2:
27342739
version "8.2.2"
27352740
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.2.tgz#9363ce84c10c9a40e6c753748e1441b60c8a0b81"
@@ -5960,15 +5965,6 @@ gatsby-graphiql-explorer@^1.1.0:
59605965
dependencies:
59615966
"@babel/runtime" "^7.12.5"
59625967

5963-
gatsby-image@^3.1.0:
5964-
version "3.1.0"
5965-
resolved "https://registry.yarnpkg.com/gatsby-image/-/gatsby-image-3.1.0.tgz#5b40682eba42696c04bfa776fa7d8477517d3959"
5966-
integrity sha512-wF/Ck0IagcUeVCtS7E9TYYPR5w95Dgiiu5soysI92Rvjw0KIBYA2nXWcC7JO7nV9ef4UBwJR4Dy4rjHIdOPI9w==
5967-
dependencies:
5968-
"@babel/runtime" "^7.12.5"
5969-
object-fit-images "^3.2.4"
5970-
prop-types "^15.7.2"
5971-
59725968
gatsby-legacy-polyfills@^1.1.0:
59735969
version "1.1.0"
59745970
resolved "https://registry.yarnpkg.com/gatsby-legacy-polyfills/-/gatsby-legacy-polyfills-1.1.0.tgz#70b0a42d1121b04c872b6320ade0efd8b996aaa8"
@@ -5999,6 +5995,24 @@ gatsby-page-utils@^1.1.0:
59995995
lodash "^4.17.21"
60005996
micromatch "^4.0.2"
60015997

5998+
gatsby-plugin-image@^1.1.1:
5999+
version "1.1.1"
6000+
resolved "https://registry.yarnpkg.com/gatsby-plugin-image/-/gatsby-plugin-image-1.1.1.tgz#b23789c105fda88196d846fc55e3fc290f1a99e5"
6001+
integrity sha512-8CIldGsS9ZQguVoIMNz3DAfU5GiQc1ez9hJTzlfqUusGbn8UdoVBnlVSVYWG0H0FKFnXuh+6ELksw6vvOGKS4g==
6002+
dependencies:
6003+
"@babel/code-frame" "^7.12.13"
6004+
"@babel/parser" "^7.12.5"
6005+
"@babel/traverse" "^7.12.5"
6006+
babel-jsx-utils "^1.1.0"
6007+
babel-plugin-remove-graphql-queries "^3.1.0"
6008+
camelcase "^5.3.1"
6009+
chokidar "^3.5.1"
6010+
common-tags "^1.8.0"
6011+
fs-extra "^8.1.0"
6012+
gatsby-core-utils "^2.1.0"
6013+
objectFitPolyfill "^2.3.0"
6014+
prop-types "^15.7.2"
6015+
60026016
gatsby-plugin-manifest@^3.1.0:
60036017
version "3.1.0"
60046018
resolved "https://registry.yarnpkg.com/gatsby-plugin-manifest/-/gatsby-plugin-manifest-3.1.0.tgz#9a40e2c7355663ea0863b199e7ba92af2f655e8d"
@@ -9158,11 +9172,6 @@ object-copy@^0.1.0:
91589172
define-property "^0.2.5"
91599173
kind-of "^3.0.3"
91609174

9161-
object-fit-images@^3.2.4:
9162-
version "3.2.4"
9163-
resolved "https://registry.yarnpkg.com/object-fit-images/-/object-fit-images-3.2.4.tgz#6c299d38fdf207746e5d2d46c2877f6f25d15b52"
9164-
integrity sha512-G+7LzpYfTfqUyrZlfrou/PLLLAPNC52FTy5y1CBywX+1/FkxIloOyQXBmZ3Zxa2AWO+lMF0JTuvqbr7G5e5CWg==
9165-
91669175
object-inspect@^1.8.0, object-inspect@^1.9.0:
91679176
version "1.9.0"
91689177
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.9.0.tgz#c90521d74e1127b67266ded3394ad6116986533a"
@@ -9249,6 +9258,11 @@ object.values@^1.1.0, object.values@^1.1.1:
92499258
es-abstract "^1.18.0-next.1"
92509259
has "^1.0.3"
92519260

9261+
objectFitPolyfill@^2.3.0:
9262+
version "2.3.5"
9263+
resolved "https://registry.yarnpkg.com/objectFitPolyfill/-/objectFitPolyfill-2.3.5.tgz#be8c83064aabfa4e88780f776c2013c48ce1f745"
9264+
integrity sha512-8Quz071ZmGi0QWEG4xB3Bv5Lpw6K0Uca87FLoLMKMWjB6qIq9IyBegP3b/VLNxv2WYvIMGoeUQ+c6ibUkNa8TA==
9265+
92529266
obuf@^1.0.0, obuf@^1.1.2:
92539267
version "1.1.2"
92549268
resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e"

0 commit comments

Comments
 (0)