Published on

Link a Sanity account

Introduction

To link your Sanity account to Cloudpress, you will need to give Cloudpress some information about your Sanity project.

This document will walk you through the process of linking your account.

Sanity schema overview

In order to add your Sanity account to Cloudpress, you will need to have some basic information regarding the schema for the Sanity content type you will be exporting to.

You will need to know the name of the schema, the name of the field contains the title of the document, as well as the name of the field that contains the content of the document.

For the purposes of 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: 'body',
  	title: 'Body',
  	type: 'blockContent'
	}
  ],
  preview: {
	select: {
  	title: 'title'
	},
	prepare(selection) {
  	const {author} = selection
  	return Object.assign({}, selection, {
    	subtitle: author && `by ${author}`
  	})
	}
  }
}

You will also need a robot user token that will allow Cloudpress to access your Sanity account. This token can be obtained on the project page in the 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.

Linking your account

To link your account, go to the Linked Accounts page in the Cloudpress Dashboard.

Depending on whether or not you have previously linked other destination accounts, you will either see an empty account list or a list of accounts that you have already linked. If you see an empty account list, click on the Link a Sanity account button:

Alternatively, click on the Link another account drop-down menu, then select Link a Sanity account:

This will take you to the Link a Sanity account screen:

You will need an access token that will allow Cloudpress to access your Sanity account. To generate an access token, go to the Sanity Management Console and then to the Settings for the project you want to use.

Under the API section, scroll down to Tokens and click on the Add New Token button.

Give the token a descriptive name and be sure to specify the Write rights.

After the token has been generated copy it to the clipboard. Return back to the Cloudpress website, paste the token in the access token field and then click the Link Sanity account button.

Next, you will see the Sanity account configuration screen:

Cloudpress will automatically use the name from your Sanity project as the name of the linked account. You are free to rename it to something else, but keep it descriptive so you know which Sanity project and account it refers to.

Select the dataset to which you want Cloudpress to export to from the list. This list will correspond to the available datasets you have configured in your Sanity Management Console.

The document content type, title field and content field will depend on your Sanity schema. For the example schema that was 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, you can click on the Save Configuration button.

Address

Unit 346, 3/F, Peninsula Centre
67 Mody Road, Tsim Sha Tsui
Kowloon, Hong Kong

Contact

hello@usecloudpress.com

© 2020 Cloudpress Limited. All rights reserved.