Last active
February 21, 2018 16:05
-
-
Save azamatsmith/35505208187ffaaebf9d8709235e6a09 to your computer and use it in GitHub Desktop.
Gatsby Query Fragment - Multiple Images Example
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
// Your Component (anywhere in your project) | |
// | |
// Place this fragment at the bottom of your component | |
// and Gatsby will collect it prior to running any | |
// page queries | |
export const profileImageFragment = graphql` | |
fragment ProfileImage on RootQueryType { | |
mattProfile: imageSharp(id: {regex: "/matt-profile.png/"}) { | |
resolutions(width: 339, height: 339) { | |
...GatsbyImageSharpResolutions | |
} | |
} | |
rachelProfile: imageSharp(id: {regex: "/rachel-profile.png/"}) { | |
resolutions(width: 339, height: 339) { | |
...GatsbyImageSharpResolutions | |
} | |
} | |
} | |
`; | |
// Your Page in `/pages` | |
// | |
// Use the fragment that you created above in | |
// your page query like so: | |
import React from 'react'; | |
import {WhoWeAre} from 'routes'; | |
export default ({data}) => <WhoWeAre {...data} />; | |
export const query = graphql` | |
query ProfileImageQuery { | |
...ProfileImage | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment