Introduction

Sanity uses a proprietary JSON format called Portable Text. When you export content to Sanity, Cloudpress will automatically convert the content to the correct Portable Text format. It will convert your text with the formatting, headings, tables, code blocks, etc.

However, you may want to export custom content not supported by Cloudpress. For example, Sanity has Portable Text blocks such as the geopoint and file blocks, for which there is no corresponding representation in Google Docs and Notion.

Example of adding a Geographical Point in Sanity

You can edit the content in Sanity after you export it with Cloudpress to add these blocks, but that requires an extra step. Also, if you re-export the source content with Cloudpress, all your changes will be lost.

To work around this problem, Cloudpress introduced a feature called Raw Content Blocks that allows you to add the source code for Portable Text blocks like these to your source document. When Cloudpress exports your content and encounters a Raw Content Block, it will send the content of that block to Sanity as-is.

The rest of this document will walk you through this feature by demonstrating how to add a geopoint and file block your content and have Cloudpress export it correctly to Sanity.

Get the JSON representation of your Portable Text blocks

First, you must get the JSON representation of the Portable Text block(s) you want to export. Create an empty item in Sanity containing the Portable Text elements to export - in this example, a geopoint and file block.

Geographical point and file added to Portable Text editor

Next, we need to get the underlying JSON code for these blocks. To do that, open the overflow menu and select the Inspect menu item.

The Inspect menu of the Portable Text editor

Switch to the Raw JSON tab to see a text outline of the JSON for this document.

JSON view for the content

You can see the body property is an array that contains two objects that represent the geopoint and file blocks. To copy the JSON for a block, highlight the JSON code for the block you want to include in your Raw Content Block and copy it to the clipboard.

For example, here is the JSON of the geopoint:

{
  "_key":"960b58291f57",
  "_type":"geopoint",
  "lat":13.736717,
  "lng":100.523186
}

If you want to export multiple blocks, place them inside an array. We suggest you copy the JSON for each block individually to a text editor and then edit them to wrap them inside an array before you copy and paste the JSON for that array to Google Docs or Notion. Below is an example of an array containing the JSON for both the geopoint and the file.

[
  {
    "_key":"960b58291f57",
    "_type":"geopoint",
    "lat":13.736717,
    "lng":100.523186
  },
  {
    "_key":"05f63c222dff",
    "_type":"file",
    "asset":{
      "_ref":"file-1f59e84376b2acda296b1b431a16e5cd5dfb7da8-pdf",
      "_type":"reference"
    }
  }
]

Once you have the JSON for the Portable Text blocks, you can add it to Google Docs or Notion. The process differs for each and is discussed in separate sections below.

Export custom Portable Text from Google Docs

Add table with JSON

To export the Portable Text from a Google Doc, add a single-cell table to your document - in other words, a table with one row and one column.

Add a single-cell table to Google Docs

Give the table a dotted border by placing your cursor inside the table and selecting the dotted border from the Border dash toolbar item.

Add a dotted border to the table

Paste the JSON code of the Portable Text block(s) inside the table.

Paste the JSON content into the table

Next, you must configure Cloudpress to interpret the content of the table as raw content. The procedure differs depending on whether you use the Cloudpress Google Docs Add-on or the Export Content page.

Enable raw content during export

You need to tell Cloudpress to interpret the content of the table you added as raw content. This procedure differs depending on whether you export content with the Google Docs Add-on or the Export Content page

Tutorial video

The tutorial video below walks you through exporting Portable Text blocks from Google Docs to Sanity.

Export Portable Text from Notion

Cloudpress uses Code blocks to denote raw content in Notion. However, code blocks are also used when you want to include code snippets in your content. For example, you may have a blog geared towards software developers and often include code snippets in your content. In this case, you can instruct Cloudpress to treat only code blocks in a specific language as raw content and all others as code blocks.

Enable raw content for your Notion connection

Go to the Connections page in Cloudpress and click on your Notion connection. Go to the Content Conversion tab.

  1. In the Raw content blocks section, enable the option to convert code blocks to raw content. With this enabled, Cloudpress will treat all code blocks as raw content.
  2. Next, limit raw content only to a specific language. As mentioned before, this is useful when using code blocks for code snippets. In the screenshot below, you can see that Cloudpress will only treat code blocks for JSON as raw content. All other code blocks will be exported as code blocks.

Enable raw content for your Notion connection

Click Save Changes to save your changes. Cloudpress will now treat code blocks for the specified language in all pages exported from this connection as raw content.

Add the Portable Text to your Notion page

Add a code block to your page.

Add a code block to your Notion page

Paste the JSON code of the Portable Text blocks(s) inside the code block and set the language to the same language you configured in your connection settings.

The screenshot below demonstrates a code block containing the JSON code with the language set to JSON.

Add the JSON to your code block

You can now export the content to Sanity. If the code block’s language matches your Notion connection configuration, Cloudpress will export the JSON code as raw content.

Tutorial video

The tutorial video below walks you through exporting custom Portable Text from Notion to Sanity.