Carl Topham
Frontend JavaScript engineer
Visit Carl Topham's profile
Truncate block content into a shorter value to use as an excerpt
*[_type == "article" && draft != true ] | order(publishedOn desc)[0..5] {
"excerpt": array::join(string::split((pt::text(body)), "")[0..255], "") + "..."
}
This query takes a block field and creates an excerpt of the required length so that truncation doesn't need to be done on the client side.
Frontend JavaScript engineer