1

I am setting up a Gatsby website using Kentico Cloud as the headless CMS, the only issue is that it seems not possible to preview the kentico cloud content with the gatsby.

one of great feature from kentico cloud is that it has built-in workflow, which is great for company need approval before publish. There will be the situation that the approver want to view what it looks like in gatsby website, instead of just the content in kentico cloud before they approve it.

rocky
  • 7,506
  • 3
  • 33
  • 48
Steven Wu
  • 11
  • 1

1 Answers1

2

It is definitely possible to set up the preview with Kentico CLoud Gatsby source plugin.

All of the properties from JavaScript SDK configuration object could be passed to the Gatsby configuration.

So the configuration for the preview would look like this:

module.exports = {
  ...
  plugins: [
    ...
    {
      resolve: `gatsby-source-kentico-cloud`,
      options: {
        deliveryClientConfig: { // Configuration object
          projectId: `XXX`,
          previewApiKey: `YYY`,
          enablePreviewMode: true,
          typeResolvers: []
        },
        languageCodenames: [ // example language configuration
          `en-US`, // default language
          `es-ES`,
        ]
      }
    }
    ...
  ]
  ...
}
Simply007
  • 444
  • 3
  • 14
  • 1
    Thanks for your reply. I got it working, but if I make changes in kentico cloud and click the preview button, the changed-but-not-published content still can not be updated in the gatsby website. Is there anyway i can trigger a gatsby rebuild without publish the content from kentico cloud? – Steven Wu Mar 29 '19 at 10:07
  • Currently, the only way how to hook on something is a publish. There is also the possibility to hook on the email notification when you assign a contributor and change the workflow step, but this way is really hacky. So it is necessary to hit the site rebuild/restart development server manually for now. – Simply007 Mar 29 '19 at 14:23
  • Thanks Simply007, I was told by your colleague Eric that Kentico Cloud is developing a functionality to enable webhook can be triggered by a custom work flow status. If you can post an update when that feature goes live, it would be great. As basically the new feature resolve the issue i have in the first place. – Steven Wu Mar 31 '19 at 21:41
  • Yes, you are right, I didn't want to spam here. I will let you know there when the feature is released. – Simply007 Apr 01 '19 at 01:13
  • The feature is already live for quite some time: https://docs.kontent.ai/reference/webhooks-reference#a-data-object-for-workflow-events https://docs.kontent.ai/changelog/product-changelog?show=webhooks – Simply007 Apr 11 '20 at 14:15
  • So is it possible to preview without triggering a rebuilt? If not I don't see the benefit of using preview in Gatsby – Theorder Apr 18 '20 at 22:39