-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access unpublished pages for staging/preview website #30
Comments
Hey, |
I am also looking for this feature. We are using an external React frontend as preview page instead of the internal Twig engine. It needs access to preview unpublished data somehow. So access through API would be useful in a real headless situation. |
Hey, how do you plan to implement/use the preview feature with an external frontend? I am not sure if it is a good idea to provide unpublished data via a public API. As answered above, the data that would be returned by the API is available in the twig template via the |
Well, we have a NextJS front-end which will not be started from the twig template, but instead deployed as a standalone application (because of the headless situation). Several other Headless CMS's do provide a way to access unpublished or drafted content through a (secure) API endpoint with just a simple flag. I think this bundle would definitely benefit from such an implementation. Now I am using an iframe in my twig template to show my frontend in the preview pane within the Sulu admin interface. Passing the preview data with a postMessage on that iframe on every reload to provide the preview data. This is far from ideal and feels more like a hacky situation to me. Personally I would like to see a configurable URL for the preview pane and a secure way to access the (un)published data via API. |
I dont think that is a particular bad solution for previewing content 🙂 But I understand that headless-first platforms provide additional APIs for this. I see the following challenges for implementing such an API in this bundle:
That said, I am not planning to implement this by myself at the moment. While the iframe solution might feel hacky, it solves both challenges with minimal effort and without any core changes. But if anyone is interested to work on this, pull requests are certainly welcome 🙂 |
Thanks for shining your light on this matter. I think you're right about the implementing challenges. Most other platforms provide some sort of SDK or client which updates the application's state on every change from the admin form. This way you would always see the latest render of your content. For example Storyblok, they provide a content API accessible with an API token. With a simple GET param you can retrieve draft content. Such a simple token should theoretically be secure enough providing that you don't expose it to your frontend application for everyone else to exploit. Maybe a JWT based authentication could be better alternative. But that is open for discussion I guess. For the preview functionality in Sulu this would mean that it just loads the front-end url inside the already existing iframe with some preview URL params. I am not sure how to implement the onChange functionality just yet. Maybe I can try to implement it and submit a PR in the future. For now I'll use the 'hacky'solution. |
For the Preview and onchange behaviour I will link here to the following issue #65. There is an example how to call your nextJs or other application which need to provide a url to render the given data with it which should then return the html and sulu will this response then show in the preview. |
How can I access unpublished pages json to preview the aspect before publish?
The text was updated successfully, but these errors were encountered: