New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve Gatsby image data in _rawContent
#143
Comments
My amusing workaround, for now, is to populate import { graphql, StaticQuery } from "gatsby";
import { GatsbyImage } from "gatsby-plugin-image";
import { getGatsbyImageData } from "gatsby-source-sanity";
export const imageSerializer = ({ node: { asset } }) => (
<StaticQuery
query={graphql`
{
site {
siteMetadata {
sanityLocation {
projectId
dataset
}
}
}
}
`}
render={({ site: { siteMetadata } }) => (
<GatsbyImage
image={getGatsbyImageData(asset._id, {}, siteMetadata.sanityLocation)}
/>
)}
/>
); |
Is this the only way to do this? |
As far as I know. I mean - there are for sure better ways to grab But resolving the image data still needs to be done in the serializer, and is not happening inside the Gatsby graph. |
Thanks @aaronadamsCA - I was able to solve the issue with your comment. |
I'd like to see a new option in the GraphQL schema to resolve Gatsby image data in
_rawContent
.Intended usage:
Intended result: Block content objects of
"_type": "image"
would containasset.gatsbyImageData
. This could be passed directly togatsby-plugin-image
while serializing block content, for example:This would make life with block content and Gatsby a lot easier!
The text was updated successfully, but these errors were encountered: