Magnolia CMS NextJS hybrid SSG development

44 Views Asked by At

I am trying to look into the Magnolia CMS NextJS hybrid SSG project. There is a boilerplate code for a page pages/[[pathname]] which will generate static content and paths for all the pages we add in the pages app in the admincentral. This works perfectly for page authors. When we use content from content types, how do we get that into a component?

When I look at props a component receive, it only contains the values I have specified in the page editor while adding the component.

I would like to be able to develop a component which can be added to a page via editor, which lists a list of content from a content type. Is there any way we can do this?

1

There are 1 best solutions below

2
Topher Z On

yes this is supported.

The key is that you want the REST Delivery Endpoint to return the content from any linked content in your content app. You can do this by adding referenceResolvers to the endpoint configuration.

Here is an example of an AssetReference resolver. https://git.magnolia-cms.com/projects/DEMOS/repos/minimal-headless-spa-demos/browse/magnolia/light-modules/spa-lm/restEndpoints/delivery/pages_v1.yaml#18

You will want to add a jcrReferenceResolver which specifies your propertyName. See the docs here: https://docs.magnolia-cms.com/product-docs/6.2/Developing/API/Delivery-API/Resolving-references-with-the-delivery-endpoint.html#_example_configuration