Add webhook trigger on document draft save

Feature Idea:

Currently there is no option to trigger a webhook when a draft/modified document is saved (but not published, or scheduled for future release). Saving the document generates a unique ref, so it would make sense to make that available in a webhook.

I would put the webhook under Documents and maybe call it "A document draft is saved". It should only run when a new draft is saved (or re-saved), or a published document is modified and (re-)saved, but not when it is published or scheduled for release (as there are separate hooks for these).

Issue that it solves:

Statically generated sites currently can't generate static preview pages for documents that have been saved, but not published, because there is no webhook trigger that would make the SSG generate a page for the particular draft ref at the point of saving the document.

Meanwhile within the preview webhook you can't distinguish what is being previewed (e.g. is it a live page that does not need to be generated?), and in any case generating the page at the point of viewing it isn't ideal, or might not even be possible, depending on the set up.

This applies to new pages still in Draft stage, but also Published pages that have been modified and need to be previewed before publishing.

2 Likes

Hello Martin,

Sorry it took so long to get back to you on this.

What technology is your website project built in, because previews for SSG websites should still work for unpublished drafts?

Also I'm not sure what you mean by previews making it hard to distinguish what is live and what is a preview. When you click Preview on a document you are only previewing that document, everything else should be live, unless it's part of a release, in that case everything in the release will be drafted.

This isn't likely to be something that we will implement as our preview system utilises cookies to add the content on top of your application in the browser. This saves users building previews in their application, saving on processing costs.

I'll be happy to help you implement your project correctly so that you can use previews for drafts and any other use case you might have.

Thanks.

Hi Phil,

I'm using Eleventy (though the particular SSG isn't important), and deploying on Netlify. In my Prismic repo I've set up the webhook to connect to a Netlify build hook which queries the Prismic API to get all the data and builds a static html site out of it.

I'd like to do the same with the Preview, i.e. when I save a draft, this will trigger Netlify to built a static html page (of the previewed page) via the abovementioned flow.

What is the alternative?

Hey Martin,

It sounds like maybe you haven't added the preview script to your 404 page so it's not redirecting to the correct page to build your unpublished draft preview. Can you try this?

Thanks for getting back, I was wondering what technology your project was built in like node.js, react or vue? Because we have development kits that would make implementing previews easy.

Thanks.

This issue has been closed due to inactivity. Flag to reopen.