WebDevStudios / wds-headless-wordpress

This codebase has been moved to a monorepo. Please see the documentation to learn more. 🍻
https://github.com/WebDevStudios/nextjs-wordpress-starter
GNU General Public License v2.0
32 stars 15 forks source link

Internal links in blocks do not use FE domain #23

Closed ravewebdev closed 2 years ago

ravewebdev commented 3 years ago

When adding a link to text or a block in the Block Editor, links to other site posts/pages use the WP/BE domain instead of the FE domain. This will need to be modified to use the FE domain (similar to how it's done in the View Post permalink domain) so links work properly on the FE. Currently, these links just redirect to the FE homepage instead.

Screen Shot 2021-04-22 at 10 28 57 AM

donmhico commented 3 years ago

I've been looking into this and there are a few approach in mind.

  1. The link results are from /wp/v2/search as seen here. So we can change URLs of the search results on Search endpoint. The trade-off is, while we are just editing the URLs of post types results, the official docs discourages modifying responses of core endpoints.

  2. "Links" are saved as normal post content and not some block attributes. We can perform search and replace action on post save.

  3. Create our own URL Input implementation so it will hit our own search endpoint which handles the URLs. This way we won't need to modify wp/v2/search endpoint. I've been trying to find a way to modify / filter the built-in URL Input but I can't seem to find a way to do so.

References: