aem-spa-project-core icon indicating copy to clipboard operation
aem-spa-project-core copied to clipboard

[feature] Mapped/short URLs in PageImpl

Open dgonza opened this issue 4 years ago • 2 comments

In a project when using React and SSR I'm having problems trying to use short URLs defined by sling mappings. The react router is configured to use the full page path provided by the PageImpl model. When using the dispatcher, the routes won't match the current page path showing a blank page.

It would be great if we can have an additional property with the mapped/short path too. Removing the initial /content/site is not enough when the sling mappings are more complex than just shortening the URL. Having this property would make really easy to modify the React route paths to consider the mapped path too:

<Route
  key={routePath}
  exact
  path={['(.*)' + routePath + '(.' + extension + ')?', this.props.mappedPath]}
  render={routeProps => {
    return <WrappedComponent {...this.props} {...routeProps} />;
  }}
/>

At the moment my workaround to this issue is implementing a Jackson Module Provider that adds a property containing the mapped path to the PageImpl model and a custom Remote Content Renderer Request Handler to configure the Object Mapper instance.

Other alternative is implementing our own Page model, but this basically means duplicating a lot of code that already exists here. The PageImpl class is not exported by the bundle so I can't extend it and reuse its logic.

Any thoughts or suggestions? Thanks

dgonza avatar Jan 06 '22 19:01 dgonza

Thanks @dgonza - looks like we are facing the same issue, https://github.com/adobe/aem-spa-project-core/issues/43 seems to be the same.

nhirrle avatar Jan 11 '22 08:01 nhirrle

@nhirrle yep, created almost at the same time too 😆 Aliases will be helpful as you've mentioned in #43

dgonza avatar Jan 11 '22 13:01 dgonza