Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

I’m trying to create textual documents which can have inline references to other such textual documents.

5 replies
Last updated: Sep 10, 2020

Hi! I’m new here, new to Sanity and would like to get some help.I’m trying to create textual documents which can have inline references to other such textual documents. What I managed to do so far is to insert a reference, but as a separate block, not inline.

Would it be possible to insert a reference to another document inline?

Sep 10, 2020, 8:35 AM

If i understand correctly, instead of making a reference, you need to add the field as

type: 'your-other-document'
this will load the document fields inside your document.

Sep 10, 2020, 8:49 AM

user H
Thank you for the quick response.Unfortunately, I’m not sure I understand what you mean.
I am happy with references, I don’t want to load the whole content of the other document, its name is enough. I would like to be able to insert such a reference in the editor as an inline element, part of the text block.
Like:
The sun is a mid sized star in our
SOLAR_SYSTEM
. It has 8 planets, including
EARTH
.In this example, the highlights are references, inserted from a given collection.

Sep 10, 2020, 9:00 AM

I was thinking about using annotations as well, but it requires to select some text first, which is against the use case. So, inserting would be much better.

Sep 10, 2020, 9:00 AM

https://www.sanity.io/docs/block-type#example-schema-block-array-with-custom-types-OFzEUqst you should add it under the

of
key in the block type object to make it inline

Sep 10, 2020, 9:17 AM

That’s it! thank you!

Sep 10, 2020, 9:19 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.