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.

1 Like

Next.js has posted some CMS examples taking advantage of their preview mode.

They have said they’re working on more, but doubt that WordPress is on their radar.
Not entirely sure how one would accomplish because all the modern CMS’s have the feature built into them. Would the native WordPress preview need to be modified to work or a separate plugin to attach an additional “Frontity Preview” mode?

Also these guys are taking the preview functionality to the next level: https://tinacms.org/
I know Vercel is working on an example for the above.

Hey @b-bot, thanks for the heads up. Yeah, I saw that a while ago but it’s not really relevant for Frontity and WordPress. We are going to solve it with our PHP plugin and it will work with the native WordPress preview button :slightly_smiling_face:

I guess that’s something that the Gutenberg team should have to work on. If they ever do, we will integrate it with Frontity, of course.

Any ETA for plugin?

Thanks

We consider that the plugin is going to be pretty useful for Frontity users so it’s one of our top priorities. However, I’m sorry there’s no ETA yet. We’re currently doing some research about the best way to approach it, which features should be included in the first version, and trying to figure out a simple interface for everything. Once this research is finished, we should be able to start working on the development.

We’ll keep you posted :slightly_smiling_face: In the meantime, you can take a look at the discussion we’re having at this Feature Discussion, as it’s going to be an important part of the plugin.

@SantosGuillamot Thanks for the reply! we already started the project with frontity

3 Likes

We are going to do a proof of concept of the preview in our next sprint. This is the proposal:

If this approach works well, we will do a proper implementation proposal.

2 Likes

I’ve created a proper Feature Discussion to keep the conversation there.