Add handling for Next.js static paths in Drupal
The Next.js entity preview feature is really powerful! It would be really useful to be able to do something similar with Next.js static paths.
For example, I have a static path for /articles in a Next.js site which is linked in a menu. If I click that link from the menu view, it leads to a 404 page on Drupal which is not great UX.
Potential solutions
- Render a page similar to entity preview that allows previewing the page in any of the Next.js sites where the static path is available. This would require having access to the static paths provided by each of the Next.js sites.
- Potentially simpler solution would be to add feature that would simply enhance the 404 page to include something like "404 on Drupal but maybe you meant to navigate to one of the Next.js sites instead? Here are links for all of the sites: https://localhost:3000/articles, https://next-drupal.org/articles"
Adding this to the list of features to consider for #217
As a temporary solution, if you want to prevent navigation on link click inside the iframe, you can add the static paths to Skip routes. See https://next-drupal.org/guides/route-syncing#skipping-routes
Another idea: Create a content representation of a next.js static path in Drupal that could be linked into the menu and, when visited, either showed the site preview at the given route or redirected to the site itself.
This could be done through a Site reference field which allowed you to choose the site the entity represented. You could then ship a Static Path Content Type with the site reference field. This also allows the content entity to be added natively into Drupal menus too.
@fiasco This is an interesting solution. We're using this on our own site where we have a blog landing built on the Next.js site. On Drupal, we created a temporary page which resolves to this same url.