SPA++ linking to document in page

In a SPA mount while resolving link to a document in a page I am getting a link with the resourceAPI in the URL:
eg:“url”: "/site/resourceapi/sample-linking"

The code to resolve the link is the following:
reqContext.getHstLinkCreator()
.createCanonical(linkBean.getNode(), reqContext)
.toUrlForm(reqContext, false);

For purposes of routing, I think this link should be pointing to the standard pipeline, like this: /site/sample-linking

What would be best way to achieve this in a SPA mount?

Hi Nuno,

In an HstComponent, create an HstLink using the parent mount of the current mount of HstRequestContext and set it to a model through HstRequest#setModel(…). Then, it will be shown in a model of the component.
Or do you need another way or different use cases?

Regards,

Woonsan

Hi Woonsan,

That works fine, but I was looking for a solution on the API or configuration level.
I understand that from the CMS perspective it makes sense to render links to the “resourceapi/” OOTB, but in SPAs that is not applicable since these links are going to be consumed by the frontend and it’s not very practical to be stripping out the “resourceapi”. With this solution, the backend code will have to render all the links to the parent mount, which feels a bit strange.
Also in a multi-channel set-up is it the parent always the Site mount?

Thanks,
Nuno

Why don’t you just use HST Menus? Then the menu will be serialized into JSON with site link by default.

Woonsan