Contentful

Adding Shopstory field to a content type

Shopstory content can be added to any of your content types by adding 3 consecutive fields:

  1. id: fieldId, type: JSON, localisation: on, appearance: Shopstory App

  2. id: fieldIdReferences, type: Reference (many), localisation: off

  3. id: fieldIdMediaReferences, type: Media (many), localisation: off

The first field is the main JSON field that stores Shopstory visual content.

The references and media references fields (2. and 3.) display all the references used by Shopstory content. Thanks to them users can easily see the status of entries linked by Shopstory content (published / draft / changed), they also makes the "References" Contentful tab works properly.

Naming convention is super important! The main JSON field can have any id but in order to correctly find its references and media references Shopstory requires 2. and 3. to be named {id}References and {id}MediaReferences. This allows Shopstory to correctly connect main JSON field with its references field.

Can I add more than one Shopstory field in a content type?

There is no limitation in terms of how many Shopstory fields are added to a single content type. For example, if ecommerce product page has a standard product head section (with gallery, product info and buy button), the extra content blocks can be allowed both at the top and at the bottom of the section. In this scenario adding 2 separate Shopstory fields is recommended.

Built-in resource types

There are 2 built-in resource types:

  1. contentful-asset

  2. contentful-entry

contentful-asset

contentful-asset resource type takes 1 parameter:

  • mimeTypeGroups - array of mime type groups allowed by Contentful, for example image or video

{
  prop: "someEntry",
  type: "resource",
  resourceType: "contentful-asset",
  params: {
    mimetypeGroups: ['image']
  }
}

Default fetch for contentful-asset is a standard asset fetch by Contentful Client SDK.

contentful-entry

contentful-entry takes 1 parameter:

  • contentTypeId (string | string[]) - a list of content types allowed

Code example:

{
  params: {
    contentTypeId: [`ContentType1`, `ContentTypeId2`]
  },
  prop: 'link',
  resourceType: 'contentful-entry',
  type: 'resource'
}

Default fetch for contentful-entry is a standard entry fetch by Contentful Client SDK with include: 5.

Last updated