Does Frontity support Wordpress post preview?

As title said.

I wanna know does Frontity support the feature like wordpress draft / preview and published / preview?

Thanks.

Hello @onlylinihung welcome to Frontity!

The post preview is not yet released, but is a priority and we want to release it as soon as possible. @luisherranz has been working in a Proof of Concept for the “Theme Bridge” (an alternative way to use Frontity instead of the direct to Frontity installation) and he is going to start working now on the PoC of the preview as it is really related to the theme bridge.

Btw, @onlylinihung could you share with us what you are trying to build? We would like to understand your use case :blush:

2 Likes

Might be worth taking a look at how Craft CMS does live previews in headless mode by passing a header param + token:

Thanks @Tittyfront!

Yes, actually that is the first approach we are going to try. Thanks for the share, I’ll take a look :slightly_smiling_face:

Great read. They ended up writing an article: https://nystudio107.com/blog/headless-preview-in-craft-cms

This is my current idea:

Open Image

The JWT generated contains information in its payload about:

  • The expiring time
  • The post ID

The expiring time for the normal preview is 60 seconds, enough time to send the request to Frontity and Frontity send the request back to the REST API. After those 60 seconds it is not valid anymore.

A new token is generated for each request (each time the user clicks on the Preview button). That is because each time the expiring time changes, that means that the payload is different and the token is different.

The expering time for the publicly sharable link is infinite. That means that the token is always the same. To avoid having to save token in the database, just a post meta "public-share" setting is saved. The non-expiring token is only valid if that post meta is true. Disabling the sharable link simply turns the "public-share" meta to false.

The secret key used is a constant that the user needs to define in wp-config.php named PREVIEW_AUTH_KEY but it defaults to SECURE_AUTH_KEY if missing.