Last active
July 3, 2020 17:10
-
-
Save jamiejohnsonkc/2e29cc098c00747af4ec1727eef1d442 to your computer and use it in GitHub Desktop.
query and inject multiple fluid gatsby images in page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** @jsx jsx */ | |
| import React from "react" | |
| import { Styled, jsx } from "theme-ui" | |
| import { Link, graphql } from "gatsby" | |
| import Layout from "../components/Organisms/Layout" | |
| import SEO from "./seo" | |
| import Img from "gatsby-image" | |
| export const fluidImage = graphql` | |
| fragment fluidImage on File { | |
| childImageSharp { | |
| fluid(maxWidth: 1000) { | |
| ...GatsbyImageSharpFluid | |
| } | |
| } | |
| } | |
| ` | |
| export const query = graphql` | |
| query { | |
| imageOne: file(relativePath: { eq: "bookshelf.jpg" }) { | |
| ...fluidImage | |
| } | |
| imageTwo: file(relativePath: { eq: "symposium.jpg" }) { | |
| ...fluidImage | |
| } | |
| imageThree: file(relativePath: { eq: "workshop.jpg" }) { | |
| ...fluidImage | |
| } | |
| } | |
| ` | |
| const TestingPage = ({ data }) => { | |
| return ( | |
| <Layout> | |
| <SEO title="TestingPage" /> | |
| <Styled.h4>Testing Page</Styled.h4> | |
| <Styled.h6>Image should appear below</Styled.h6> | |
| <Img | |
| className="bookshelf" | |
| fluid={data.imageOne.childImageSharp.fluid} | |
| alt="bookshelf" | |
| /> | |
| <Img | |
| className="workshop" | |
| fluid={data.imageThree.childImageSharp.fluid} | |
| alt="workshop" | |
| /> | |
| <Img | |
| className="symposium" | |
| fluid={data.imageTwo.childImageSharp.fluid} | |
| alt="symposium" | |
| /> | |
| <Styled.p> | |
| <Link to="/page-2/">Go to page 2</Link> | |
| </Styled.p> | |
| </Layout> | |
| ) | |
| } | |
| export default TestingPage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment