RFC: Previews #67
Replies: 1 comment 2 replies
-
Nice work Alex! lots of good info and ideas here! here's my 🪙 🪙: Proposal FeedbackOur proposal should be to build a plugin and provide a series of examples and docs on how to leverage that plugin. You say that other places, but the proposal sections seem to ignore the plugin. That's the core of this proposal. "Auth Required" - I disagreeWhile I agree that auth is a common requirement, I don't believe it is a requirement for this plugin or universally. By integrating auth into this, we require them to integrate our auth, which is now a public API we maintain; making this pluggable adds more code to maintain, and I just don't see why we care need this. I'd rather start simple and rely on them providing auth based on the work being done in the Auth RFC. Remember, one valid option here would be for me to make draft data publicly available in WP GraphQL. While not terribly secure, this would be a simple way for me to enable previews without wiring up a whole auth system. Combine this with setting a server to only respond to my IP, and I've created "auth" without ever touching code or JWTs. "Framework Specific Draft Mode"We definitely want to enable support for these, but I think this explicit option is the wrong choice. Based on what you say here, this only takes a specific set of data and adds it to the query param for the preview URL. If we had the ability to map any post data to any query string that'd solve this problem and the query string naming issue while being much more customizable. We could then create customizable presets for Next, Nuxt, Faust, etc. Questions
|
Beta Was this translation helpful? Give feedback.
-
Abstract
This document outlines a proposal for a customizable Preview functionality for Headless WordPress. The intent is to provide editors with a more dynamic, flexible preview experience, addressing challenges such as authentication requirements for previews, managing drafts, and handling non-public post statuses. Currently, the developer experience can be unfriendly due to complexities with post statuses and preview requirements, which this RFC aims to simplify.
Motivation
We are planning to offer a WP plugin that delivers customizable Preview functionality for Headless WordPress environments. The solution will be framework-agnostic while offering extensive configuration options, making it easier for developers and content editors to manage previews without extensive custom work.
Research
Code example: https://github.com/wpengine/hwptoolkit/tree/poc-post-previews-plugin/plugins/hwp-previews
Auth Required
Previews and non-public post statuses often require authentication. The system must securely manage access to unpublished or draft content.
Security
A common approach is to use JWT to maintain a stateless authentication state, which suits this scenario. Additionally, employing WP nonce can provide an extra layer of security and dynamic control.
FE graphql queries for 'drafts' and other non public statuses
Front-end implementations need to query for draft and non-public statuses via GraphQL. Ensuring these queries are secure and efficient is a key requirement.
Non-unique slugs for the drafts
Draft posts may have non-unique slugs, so the system needs to handle URL conflicts and ensure correct content is previewed.
No possibility to select draft as a parent for another hierarchical post type item
Drafts should not be selectable as parent items for hierarchical post types, preventing potential issues in content organization.
Variety of configuration options to dynamically set up previews for the Framework used on the FE
The plugin should support multiple frameworks by allowing dynamic configuration of preview settings, catering to various front-end environments.
Framework Specific Draft Mode
Certain frameworks (e.g., Next.js, Nuxt.js) offer their own Draft Mode implementations. The solution should integrate with these systems while maintaining a unified configuration interface.
UX in terms of WP Admin Headless previews
In the WP Admin, the preview experience is typically provided via a new tab with a filtered URL preview. Alternative approaches, such as embedding previews in iframes, have also been explored.
Proposal
We propose to develop a series of proof-of-concepts (POCs for the WP Plugin "HWP Previews") that demonstrate the core preview functionalities. This includes comprehensive documentation and code examples to guide integration efforts. Further work will be needed to refine the options and functionalities available.
Options include:
Alternatives Considered
An alternative approach would be to forgo the WP plugin functionality entirely and instead offer documentation and examples for developers to implement their own preview solutions. However, this is not ideal, as the goal is to provide a faster, more user-friendly Headless WP Previews experience.
How Do We Teach This?
The solution will be thoroughly documented within the code and accompanying readme files. Extensive descriptions for each option and setting will be provided, along with code links or inline examples directly within the plugin itself, ensuring that both developers and content editors can easily understand and adopt the functionality.
How Can You Help?
We welcome your feedback on the proposed Preview functionality. Please share any suggestions for additional features, improvements, or potential challenges that you foresee. Your input is invaluable as we work to create a more robust and user-friendly Headless WP Previews experience.
Note: This RFC might be edited during a couple of days. The changelog will be provided.
Beta Was this translation helpful? Give feedback.
All reactions