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

How to generate a document with code with an custom inputComponent?

5 replies
Last updated: Sep 24, 2020

Hello! i am trying to generate a document with code with an custom inputComponent, is it possible? can anyone guide me a little?

Sep 24, 2020, 9:44 AM

You can use the sanity client to create one

import client from 'part:@sanity/base/client'

client.create({_type: 'whatever', yourfields... })

Sep 24, 2020, 10:29 AM

wow πŸ˜„ thanks a lot, will give it a try right now!

Sep 24, 2020, 10:30 AM

let me know if it works or not, I typed it from memory so could be a different method name or something πŸ˜…

Sep 24, 2020, 10:33 AM

Of course! now i know where i can take a look at) will come back here and let you know

Sep 24, 2020, 10:33 AM

user G
Got it working! your code by memory was perfect πŸ˜„ so happy with this

Sep 24, 2020, 12:26 PM

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.