Set additional field values for Sanity
Learn how you can set additional field values when exporting content from Google Docs or Notion to Sanity.
Introduction
Cloudpress allows you to set additional field values when exporting content to Sanity. This document gives you more information on the Sanity field support in Cloudpress. Please refer to the Export additional fields to your CMS documentation for information on specifying the values when exporting from Google Docs and Notion.
The video below demonstrates exporting addition field values from Google Docs to Sanity.
Specify your Sanity field definitions
Sanity does not expose the schema of your Sanity model, so Cloudpress has no way to query the data types of your fields. Because of this, by default, Cloudpress will update the value of all your fields (except images) as a string value. However, a string value may not be valid for the field.
For example, if the data type for your field is a slug, Sanity expects a JSON object similar to the one below as the field’s value - and not a string value.
{
"_type": "slug",
"current": "this-is-the-title"
}
To work around this problem, Cloudpress allows you to specify the field types for the additional fields you want to update. You can access the additional field definitions by going to the Content Model tab of your Sanity connection.
To add a field definition, click on the Add field button.
- Specify the name of the field. The name must be the same as defined in your Sanity schema - i.e. the exact spelling and letter casing.
- Select the data type of your field as you defined in your schema.
- If the field accepts an array of values, check the Array? checkbox.
You can add more fields by clicking the Add another field button.
When all the fields are added, click the Save Changes button.
Field data types and allowed values
The table below lists the data types supported by Cloudpress, with a description and examples of value values.
Data type | Description |
---|---|
Boolean | A boolean value, i.e. true or false |
Date | A valid date as per the Date formats section below. |
DateTime | A valid date and time as per the Date formats section below. |
File | A file or a string value containing the ID of an existing asset. |
Geopoint | A latitude and longitude (and optional altitude) in https://www.w3.org/2005/Incubator/geo/Wiki/LatitudeLongitudeAltitude.html. |
Image | An image or the string value containing the ID of an existing image asset in Sanity. |
Number | A number. It can contain a sign and decimal point, e.g. 123, 123.99, -89. |
Reference | The ID of the existing item that is to be referenced. |
Slug | A valid slug, e.g. this-is-a-slug. |
String | Any string value |
Url | A valid URL, e.g. https://www.usecloudpress.com. |
Date formats
You can specify a date using just the date, the date with a time, or the date with a time and time zone specifier. The table below gives examples of each of these, along with an explanation.
Text value | Date | Explanation |
---|---|---|
2023-02-27 | Midnight (GMT) on 27 February 2023 | The date format is YYYY-MM-DD. If no time is specified, the time will be assumed to be midnight GMT. |
2023-02-27T13:45 | 1:45 PM (GMT) on 27 February 2023 | Time can be specified by appending the T specifier to the date along with the time in HH:MM format. Time is specified using a 24-hour clock. |
2023-02-27T13:45-05:00 | 1:45 PM (Eastern Standard Time/EST) on 27 February 2023 | You can add a time zone offset by adding a + or - and the offset in HH:MM. For example, -05:00 indicates https://www.timeanddate.com/time/zones/est. As another example, if you want to specify the time in https://www.timeanddate.com/time/zones/ict, you can use +07:00. |