[PAGES-560] SPA renderer supports site prototype, including baseUrl and routeTemplate Created: 19/Oct/21  Updated: 14/Apr/22  Resolved: 28/Feb/22

Status: Closed
Project: Magnolia pages module
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.17

Type: Improvement Priority: Critical
Reporter: Robert Šiška Assignee: Dai Ha
Resolution: Fixed Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: 1d
Original Estimate: Not Specified

Attachments: File config.modules.multisite.config.sites.vue-lm.yaml     File prototype.yaml     File standard.yaml    
Issue Links:
Relates
relates to PAGES-514 Drop "class" prop for "renderType: spa" Closed
documentation
to be documented by PAGES-564 DOC: baseUrl and routeTemplate work i... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Documentation update required:
Yes
Date of First Response:
Epic Link: External SPA Backlog
Sprint: DevX 2, DevX 3, DevX 4
Story Points: 5
Team: DeveloperX

 Description   

Previously the spa renderer did not support the site template prototype feature, now it does.

This is a convenient and preferred way to have every template in a site use the same `baseUrl` and `routeTemplate` properties.

Docs:

https://docs.magnolia-cms.com/product-docs/6.2/Templating/Site-definition/Template-prototype.html

 

Problem description

Currently baseUrl and routeTemplate properties are not supported by the site "template prototype" feature which makes projects cumbersome to work with, and is an obstacle for customers to adopt the "external SPA" feature.

Implement support for "baseUrl" and "routeTemplate" properties in the out-of-the-box site template prototype feature.

Tech note

Docs: https://docs.magnolia-cms.com/product-docs/6.2/Templating/Site-definition/Template-prototype.html

It appears that the default class does not support the needed properties, info.magnolia.module.site.templates.PrototypeTemplateDefinition

Docs on "baseUrl" and "routeTemplate:

https://docs.magnolia-cms.com/product-docs/6.2/Developing/SPA-development-and-Magnolia/SPA-hosting.html#_connecting_an_external_spa

 

Sample Project

I've (Topher) prepared a sample of what I would expect to work. In preparing it I first just try to get the site "template prototype" feature to work with SPA rendering at all by using the case of the "area" definition. But I could not get even this to work, so maybe there are some more fundamental issues with the site "template prototype" feature - but its also possible I don't have things configured correctly.

Please see branch: "site-test" (it just has one commit.)

https://git.magnolia-cms.com/projects/DEMOS/repos/minimal-headless-spa-demos/browse?at=refs%2Fheads%2Fsite-test

The sample uses the "react-minimal" project.

I was running it on DXCore with the travel demo installed.

The branch is currently setup to just use the "main" area as a test case. It is expected that if I edit the sample "react-minimal" page, that the "main" area is editable, but in my tests it was not editable.

But you can also see the baseUrl and routeTemplate properties are configured (but commented out..)

 

 

It probably makes more sense to keep baseUrl and routeTemplate in the site configuration instead of template definition.
Continue to allow it to be specified in the page template. If specified in site and page - then the value in page is used.



 Comments   
Comment by Tobias Kerschbaum [ 17/Jan/22 ]

For us at Services especially in the Demo Team, with our e-commerce demo it is unfortunately not possible to update to the new SPA renderer without having a way to configure the base URL per site. 

Also, for several customers it was extremely important long awaited feature to finally get this possibility. And also, these customers will not be happy to learn that they have fewer possibilities in the official module than in the familiar incubator module. Unfortunately, this is not the first time that this has happened.

In our specific case, we currently have 6 different sites. Each of these pages is accessible from a different domain, but uses the same template. This use case is very common and should be supported by default. However, this is only possible if we can maintain the at the page itself, where the external frontend of this page is located.

Comment by Robert Šiška [ 03/Feb/22 ]

I agree that template prototype seems like a perfect place for it. Maybe creating a SPA version of `PrototypeTemplateDefinition` is all that's needed.

Generated at Mon Feb 12 06:20:08 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.