
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a syntax error in your GROQ query - you're missing a closing brace! Looking at your query structure, the issue is that you have a backtick in the wrong place that's breaking the template literal.
Here's the corrected version:
const query = groq`*[_type == "project"]{
title,
mainImage,
createdAt,
"excerpt": array::join(string::split((body[0].children[0].text), "")[0..100], "") + "..."
}`;The problems in your original code were:
*[_type == "project"]{ which broke the template literal{} needs to be properly closed before the closing backtickAlso, a friendly tip: this excerpt approach will work, but it's a bit fragile since it directly accesses body[0].children[0].text which will break if your body structure is different. You might want to consider using the pt::text() function for Portable Text, which is more robust:
const query = groq`*[_type == "project"]{
title,
mainImage,
createdAt,
"excerpt": pt::text(body)[0..100] + "..."
}`;This will extract plain text from your entire Portable Text body field regardless of its structure, then take the first 100 characters. Much cleaner! 😊
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store