From 9f8c2a5d4a7195e7092a103e0c9140e44ca44141 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Thu, 18 Jan 2018 10:19:32 -0800 Subject: [PATCH] Add sample code showing off gatsby-image + image processing to query with GraphQL page (#3589) * Add sample code showing off gatsby-image + image processing to query with GraphQL page * Update querying-with-graphql.md * Update README.md --- docs/docs/querying-with-graphql.md | 27 +++++++++++++++++++++++++++ packages/gatsby-image/README.md | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/docs/querying-with-graphql.md b/docs/docs/querying-with-graphql.md index 34f0b33b17079..5eddb46964d36 100644 --- a/docs/docs/querying-with-graphql.md +++ b/docs/docs/querying-with-graphql.md @@ -159,6 +159,33 @@ Gatsby has rich support for processing images. Responsive images are a big part Combined with a special Gatsby image component, [gatsby-image](/packages/gatsby-image/), you have a very powerful set of primatives for building sites with images. +This is what a component using `gatsby-image` looks like: + +```jsx +import React from "react"; +import Img from "gatsby-image"; + +export default ({ data }) => ( +
+

Hello gatsby-image

+ +
+); + +export const query = graphql` + query GatsbyImageSampleQuery { + file(relativePath: { eq: "blog/avatars/kyle-mathews.jpeg" }) { + childImageSharp { + # Specify the image processing specifications right in the query. + # Makes it trivial to update as your page's design changes. + resolutions(width: 125, height: 125) { + ...GatsbyImageSharpResolutions + } + } + } + } +`; + See also the following blog posts: * [Making Website Building Fun](/blog/2017-10-16-making-website-building-fun/) diff --git a/packages/gatsby-image/README.md b/packages/gatsby-image/README.md index bd850e352dea8..386bdce2f7abf 100644 --- a/packages/gatsby-image/README.md +++ b/packages/gatsby-image/README.md @@ -78,7 +78,7 @@ plugins: [ ## How to use -This is what a component using `gatsby-images` looks like. +This is what a component using `gatsby-image` looks like: ```jsx import React from "react"; @@ -95,7 +95,7 @@ export const query = graphql` query GatsbyImageSampleQuery { file(relativePath: { eq: "blog/avatars/kyle-mathews.jpeg" }) { childImageSharp { - # Specify the image processing steps right in the query + # Specify the image processing specifications right in the query. # Makes it trivial to update as your page's design changes. resolutions(width: 125, height: 125) { ...GatsbyImageSharpResolutions