In order to make Shopstory work properly you must pass both preview token and standard Contentful access tokens.
Let's build some content!
During installation of Shopstory Contentful app, a new content type is added to your space: "Shopstory Block". It's a very simple content type representing a piece of visual content.
In order to build your first visual content just create a new "Shopstory Block" entry, click the button "Open visual editor" and build something:
Content modeling with Shopstory
From the content modeling perspective Shopstory Block is just a starting point. It can be referenced by other content types representing for example landing pages or product pages. If you don't like references you can also add Shopstory field directly in your content types. To learn more about content modeling with Shopstory read this guide.
Displaying content
The last step is to render Shopstory content in your project. For the demo purpose we'll create a page that renders Shopstory Block entry by id - pages/shopstory-block/[entryId].tsx:
Most of the code is CMS-agnostic and relates to how Shopstory SDK works (ShopstoryClient, ShopstoryMetadataProvider, Shopstory, etc). This will be explained in the next chapter: Displaying Content.
However, there are 2 Contentful-specific pieces of code here.
First one is the body of the fetchShopstoryContentJSONFromCMS function. As you can see it's a standard call to Contentful API that fetches Shopstory JSON field content. In this example we fetch the field named content from the built-in Shopstory Block content type. It's a standard Contentful JSON field and we can access its value via entry.fields.content.
The second Contentful-specific piece of code is here:
Here we tell the Shopstory-Contentful Plugin if the Contentful resources linked in Shopstory content (media and entries) should be fetched with Content Preview API (preview: true) or Content Delivery API (preview: false).
Further reading
Now it's time to read Displaying Content chapter and understand how Shopstory SDK works.
getStaticPaths implementation is dummy just for the sake of demo simplicity.