I am attempting to query for an image in a rich text field in Contentful. What should my query look like? Here is my query:
query {allContentfulBlogPost (
sort: {
fields: publishedDate,
order: DESC
}){
edges {
node {
title
slug
publishedDate(formatString: "MMMM Do, YYYY")
body {
raw
references {
... on ContentfulAsset {
contentful_id
fixed(width: 1600) {
width
height
src
srcSet
}
}
}
}
}
}
} }
And this is the code in my editor. The image will not display.
const Blog = (props) => { const options = {
renderNode: {
"embedded-asset-block": (node) => {
const alt = node.data.target.fields.title["en-US"]
const url = node.target.sys.id.references.fixed.src
return <img alt={alt} src={url} />
}
}
} This is the raw data response from my query:
"raw": "{"nodeType":"document","data":{},"content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Here is a recipe for chewy chocolate chip cookies.","marks":[],"data":{}}],"data":{}},{"nodeType":"embedded-asset-block","content":[],"data":{"target":{"sys":{"id":"3eIIsGhe0e1my0IRJtstRp","type":"Link","linkType":"Asset"}}}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}",
question from:https://stackoverflow.com/questions/66061787/how-to-query-for-an-image-in-rich-text