✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Discussion on using localized bodyPortableText in query and combining language parameter, coalescing and expanding array content in projection.

4 replies
Last updated: Jun 2, 2020
Hi! I’m having trouble using a localized bodyPortableText in query. I used the
localeString
example but switched the used type from
string
to
bodyPortableText
. How do I now combine the use of language parameter, coalescing and expanding the array content of the
bodyPortableText
in the projection? 😬
Jun 2, 2020, 6:13 AM
Nevermind again, just figured it out 🙂
Jun 2, 2020, 6:16 AM
Here is the projection that worked:
"terms": coalesce(terms[$language], <http://terms.fi|terms.fi>)[] {
        ...,
        children[]{
          ...,
          "asset": asset->
        }
      }
Jun 2, 2020, 6:16 AM
Thanks for sharing! We should probably add this to the documentation on l10n/portable text 🙂
Jun 2, 2020, 12:00 PM
Thanks for sharing! We should probably add this to the documentation on l10n/portable text 🙂
Jun 2, 2020, 12:00 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?