Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Mapped/short URLs in PageImpl #44

Open
dgonza opened this issue Jan 6, 2022 · 2 comments
Open

[feature] Mapped/short URLs in PageImpl #44

dgonza opened this issue Jan 6, 2022 · 2 comments

Comments

@dgonza
Copy link

dgonza commented Jan 6, 2022

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

@nhirrle
Copy link

nhirrle commented Jan 11, 2022

Thanks @dgonza - looks like we are facing the same issue, #43 seems to be the same.

@dgonza
Copy link
Author

dgonza commented Jan 11, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants