Apostrophe CMS Main Site Forum Home

Headless theme development (how to deal with previews)


#1

Hi there,

New to Apostrophe. The system and it’s features looks promising :slight_smile:

I’m a frontend developer on the lookout for the perfect headless CMS. I’m really for front-end-agnostic web development. It means that i can focus as a developer on one framework and one language. Until now i’ve mainly worked with Wordpress and it’s REST API. Thus theme development in a headless sense. However Wordpress can quickly feel sluggish. Adding to that; it still centers around traditional Wordpress-php-theme-development. Out of the box, when developing a ‘headless theme’, you don’t have a clean or nice way to generate previews of posts before publishing them.

If I were to use Apostrope, the Apostrope UI and the apostrophe-headless module to develop headless themes, is there a documented method for dealing with previews? Cockpit CMS for example deals with this by loading the end site via an iframe and posting (postMessage) a corresponding JSON-formatted response to the site.

I know this is not a straightforward request, but maybe someone can point me in a direction.

Cheers,
Lasse


#2

Hmm. I’m not 100% sure where you’re going with this, let’s define terms a little…

To a lot of people, “headless” means they are using Apostrophe’s admin UI as a backend, but the public-facing application or site doesn’t use pages generated directly by Apostrophe.

If this is what you mean, preview is pretty easy: you can just rough in as much of an Apostrophe website as you want as your backend preview of the content.


#3

Hay. Thanks for the reply.

To a lot of people, “headless” means they are using Apostrophe’s admin UI as a backend, but the public-facing application or site doesn’t use pages generated directly by Apostrophe.

Indeed. This is what i intend. It’s straight forward to make a front-end/a public-facing application which pulls the right content from the REST API.

It get’s trickier the moment when you want to preview draft/unpublished content on the frontend/the public-facing application. Then you’ll have to authenticate your self (bearer/oauth…). I want to avoid the user to ‘login/authenticate’ himself via the backend and via the frontend/the public-facing application to be able to preview unpublished content. Does this make any sense?

Alternatively: how would you write a headless theme/ a public-facing application (react/vuejs/angular etc) using the REST API and Apostrophe’s admin UI as a backend while also being able to view unpublished/draft content?

Cheers


#4

Hmm, if you were to make unpublished content visible to the public in any way, then you are compromising the security of that… potentially anyone could discover that content. I’m not sure why you would want to do that, it doesn’t sound “unpublished” to me (: