Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: + MGNLFE-12
HTML Wrap
alignright
classmenu

Related topics:

Since the 6.2 LTS release, marketers and content practitioners can edit a JavaScript-based SPA (such as React or Angular) in the Magnolia Page editor in the same way they would edit a traditional website. This means developers can implement a headless approach with all of its advantages, and yet content authors still get the control, context and high-fidelity preview of the Page Editor.

...

  • Develop and host a JavaScript SPA. It could be hosted on a Magnolia instance or another delivery platform such as a CDN, front-end app server like Next, or any other server. Currently, Angular and React are supported.
  • Connect the SPA to the REST endpoints of the Magnolia public instance which will serve page content and template information to the SPA. 
  • Make sure that page , area and component templates developed in the front-end framework are correctly mapped to their Magnolia counterparts, and that besides the indexthe page template definition (using the SPA root index.html file you ) correctly reference references all CSS and JavaScript files assembled by the front-end framework.

...

The rendering of an SPA page is done through the JavaScript libraries included in the external React or Angular frameworkMagnolia JavaScript libraries available via npm (@magnolia/react-editor and @magnolia/angular-editor). The libraries assemble a component tree from the REST-delivered content and templates.

...

All content editing is done in the Pages app of the Magnolia author instance. The Magnolia-provided SPA renderer libraries ensure that a SPA project can be edited in the Pages app. The SPA renderer produces template annotations, which the Pages app transforms into the green toolbars – editable page elements. Note: The green toolbars are generated whenever the page iFrame is loaded. Additionally, the green toolbars can also be generated by calling the document.mgnlRefresh() function.

The renderer libraries allow you to work with page hierarchies in the same way you would expect when creating non-SPA pages. SPA applications can load content from different Magnolia pages. The content can be organized using a navigation component or through back and forth buttons.

Example

The angular-minimal is a parent page to the about page:

Image Added

Content of both pages is freely accessible to the editor of an SPA application and links to both pages are placed next to each other on a blue navigation bar:

Image Added Image Added

On the Magnolia side, an SPA has a very simple template definition that just references the index.html file generated by the external React or Angular app.

SPA editing tutorial

Walk through the steps of adding new dynamic components to a managed SPA:

Hello Magnolia - SPA

Browse a minimal demonstration project:

Minimal Headless SPA Demo

See also