Querying for image URLs in a content array in Sanity
You need to "dereference" the asset reference in your GROQ query to get the full image URL. Right now you're just getting the reference object, not the actual asset data.
Here's how to fix your query:
*[_type == "entry"] | order(date desc, _updatedAt desc) {
_id,
title,
date,
excerpt,
content[] {
...,
_type == "image" => {
...,
asset->
}
},
topics,
"slug": slug.current,
}The key part is asset-> - the -> operator follows the reference and expands it to include the full asset document, which contains the url field.
Alternatively, you can be more explicit and just grab the URL directly:
*[_type == "entry"] | order(date desc, _updatedAt desc) {
_id,
title,
date,
excerpt,
content[] {
...,
_type == "image" => {
...,
"url": asset->url
}
},
topics,
"slug": slug.current,
}This will add a url field to your image objects in the content array that contains the full CDN URL like https://cdn.sanity.io/images/....
If you want to use Sanity's image transformation features (recommended for optimized delivery), you can use the @sanity/image-url package on the frontend. But getting the URL directly like this works too if you just need the base image URL.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.