Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

How to use references as block types in Sanity portable text

3 replies
Last updated: Oct 2, 2024
Is it not possible to set references as a block type for portable text? If is it possible, how can I join that reference in GROQ?
defineField({
	name: 'content',
	type: 'array',
	of: [
		{ type: 'block' },
		{
			type: 'reference',
			to: [{ type: 'reputation' }],
		},
	],
}),
Oct 2, 2024, 11:17 PM
You can, but it’s best practice to wrap your reference in an object. See the Internal Link example here . You can also see an example for how to query those references here .
Oct 2, 2024, 11:21 PM
Thanks for that! I'll try to wrap in an object 👍
Oct 2, 2024, 11:30 PM
God speed!
Oct 2, 2024, 11:34 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?