Sanity
Connect a Sanity account
Introduction
To connect your Sanity account to Cloudpress, you will need to give Cloudpress information about your Sanity project. This document will walk you through the process of connecting your account.
Sanity schema overview
To add your Sanity account to Cloudpress, you will need details of the schema for the Sanity document type you will be exporting content to. You will need to know the name of the schema, the name of the field that contains the title of the document, as well as the name of the field that contains the document's content.
For this guide, let’s assume that we have a schema named post
with a title
field that contains the title of the document, as well as a body
field that is defined as blockContent
that contains the content of the document.
Here is the configuration of the sample schema:
export default {
name: 'post',
title: 'Post',
type: 'document',
fields: [
{
name: 'title',
title: 'Title',
type: 'string',
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96,
},
},
{
name: 'body',
title: 'Body',
type: 'blockContent',
},
]
}
You will also need an API Token allowing Cloudpress to access your Sanity account. This token can be obtained on the project page in Sanity Management Console and will be covered in the section below.
Be sure that you either have access to the Management Console yourself or get a token from a person that does have access to it.
Connecting your Sanity account
Go to the Connections page in Cloudpress, click on the Add Connection button and then select Sanity from the list.
This will take you to the Connect a Sanity account screen. Enter a name for this connection in the Connection name field.
You will need an API token to give Cloudpress access to your Sanity account. Open the Sanity Management Console and navigate to the API tab for the project you want to use. Scroll down to Tokens and click on the Add API Token button.
Give the token a descriptive name, and select the Editor permission.
Click the Save button to generate the token.
After the token has been generated, copy it to the clipboard. Return to Cloudpress, paste the token in the API Token field and then click the Connect account button.
You will be navigated to the connection detail screen. Click on the Content Model tab.
Select the Sanity project and dataset to which you want Cloudpress to export content. The Content type, Title field and Content field will depend on your Sanity schema. For the example schema given earlier in this guide, we can use post
as the Content type, title
as the Title field, and body
as the Content field.
Once you have specified all the values, click on the Save Changes button.