> For the complete documentation index, see [llms.txt](https://docs.shopstory.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shopstory.app/cms-guides/sanity.md).

# Sanity

## Adding Shopstory field to a content type

Shopstory Sanity plugin provides a new field type `shopstory` so adding Shopstory field is as simple as:

```typescript
defineField({
    name: "field_name",
    type: "shopstory",
}),
```

## Built-in resource types

There are 3 built-in resource types for Sanity:

* `sanity.document`
* `sanity.image`
* `sanity.file`

#### `sanity.document`

`sanity.document` resource type can take 1 parameter:

* `documentType` (`string[]`) - the list of allowed document types

Example:

```typescript
{
  prop: "section",
  type: "resource",
  label: "Sanity Section",
  resourceType: "sanity.document",
  params: {
    documentType: [
      "block_banner",
      "block_twoColumns",
      "block_productsGrid",
    ],
  },
}
```

Default fetch behaviour for `sanity.document` is a GROQ call that fetches all field values without fetching deeper references.

#### `sanity.image`

```
{
  prop: "image",
  type: "resource",
  label: "Sanity image",
  resourceType: "sanity.image",
}
```

#### `sanity.file`

```
{
  prop: "file",
  type: "resource",
  label: "Sanity file",
  resourceType: "sanity.file",
}
```
