Skip to content

Adding more routing options#166

Open
ajolipa wants to merge 6 commits intodevfrom
RB-server-routing
Open

Adding more routing options#166
ajolipa wants to merge 6 commits intodevfrom
RB-server-routing

Conversation

@ajolipa
Copy link
Collaborator

@ajolipa ajolipa commented Jun 11, 2025

In this PR

Adds the following optional props to the EditionCrafter component to give users more control over how routing is handled:

  • serverNav: boolean -- If true, will configure the component not to use the HashRouter from react-router-dom, and instead use normal browser navigation or a provided navigate funciton;
  • navigate: (path) => void -- If provided, will be used as the navigation function when navigation is triggered from within the app;
  • divider: string -- If provided, will be used as the URL segment that marks the beginning of the part of the path handled by EditionCrafter. Defaults to ec/. Note that if server nav is enabled, the URL of the page on which the component appears should end with the divider (for example www.mysite.com/myedition/ec).

The advantage of offering this mode is that the non-hash routes are more easily indexed by search engines such as Google.

Notes and questions

Depending on how the consuming application's routing works, using EC in this mode might cause full page reloads on any navigation action, which can be an undesirable user experience, especially if the component is embedded on a larger page with additional content.

Basic example using Astro and Netlify SSR: https://ec-test.netlify.app/

The example highlights some of the current UX issues with this mode -- for example the panel sizing resets to the default with each page load. Possibly things like the panel widths could be stored as URL parameters to allow them to be maintained through navigation? Open to suggestions.

@ajolipa ajolipa marked this pull request as ready for review June 12, 2025 15:30
@ajolipa ajolipa requested a review from NickLaiacona June 12, 2025 15:30
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

Successfully merging this pull request may close these issues.

2 participants