-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Adding an image field (with a relative path) to .md files #1874
Comments
Judging by the error message it looks like you need to specify what attributes of the image you want. Something like this: image {
src
} Graphiq can help you know what options you have for subfields. |
@whmountains Even when I add src in, it says "GraphQL Error: Uknown field 'src' on type 'image' How would I get into GraphQL? |
Got into GraphQL, do you have any ideas on how I would start querying? |
@theiliad From tutorial part 4 section Introducing GraphiQL, you can hit |
@theiliad did you ever make a tutorial for this? |
Just ran into the same issue - the solution for me is: Subfields missing:export const pageQuery = graphql`
query ArticlesByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
frontmatter {
date(formatString: "MMMM DD, YYYY")
path
title
excerpt
author
image
}
}
}
`; Working example with subfields added:export const pageQuery = graphql`
query ArticlesByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
frontmatter {
date(formatString: "MMMM DD, YYYY")
path
title
excerpt
author
image {
childImageSharp {
resize(width: 597, height: 382){
src
}
}
},
}
}
}
`; |
=======================
Hey Fellas 😃
I'm pretty new to GraphQL, and markdownRemark is confusing me.
I'm trying to add a field to my .md files like so:
and I want to be able to use that image in the blog-post react component. (<img src{imageURL} />)
I've tried adding fields and they usually work, except I think Gatsby realizes that this one is pointing to a file and keeps on throwing errors for the graphQL syntax.
My query before adding image:
Sample .md file:
gatsby-config.js
package.json
gatsby-node.js
The text was updated successfully, but these errors were encountered: