My Gatsby/Contentful blog is using Algolia to search through blog posts. Everything is working just fine, besides displaying images.
This is the Webhook Payload that Ive created in Contentful by using the Algolia template:
{
"title": "{ /payload/fields/title/en-US}",
"slug": "{ /payload/fields/slug/en-US}",
"price": "{ /payload/fields/price/en-US}",
"category": "{ /payload/fields/category/en-US}",
"usages": "{ /payload/fields/usages/en-US}",
"rating": "{ /payload/fields/rating/en-US}",
"image": "https:{ /payload/fields/image/fields/file/url}"
}
My algolia query looks like this:
algolia.js
const contentfulQuery = `
{
allContentfulStrains {
nodes {
id
title
price
category
image {
file {
url
}
}
}
}
}
`
function pageToAlgoliaRecords({ id, title, price, image }) {
return { objectID: id, title, price, image }
}
const queries = [
{
query: contentfulQuery,
transformer: ({ data }) => data.allContentfulStrains.nodes.map(pageToAlgoliaRecords),
}
]
module.exports = queries
Now when I type gatsby build the data algolia is receiving is not structured right. View the image below. I want the structure to be - image:image.url so I can get the url of the image and past it in the hit component to display the images.
Is there something wrong with my query?
I really dont know what Im doing wrong..