Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

pathPrefix missing for local links inside content #310

Closed
henrikwirth opened this issue Nov 23, 2020 · 6 comments
Closed

pathPrefix missing for local links inside content #310

henrikwirth opened this issue Nov 23, 2020 · 6 comments
Labels
good first issue Good for newcomers topic: WordPress Related to Gatsby's integration with WordPress

Comments

@henrikwirth
Copy link

Inside content links are missing the pathPrefix in version 1.7.9.

Since I don't see anything related to it in the changelog, I suspect this is still a problem in newer versions.

@TylerBarnes Is there any way we could spin up a 1.7.10 or 1.8. only with that fix? I'm stuck on these version since I can't upgrade WPGatsby or WPGraphQL any further for now.

@henrikwirth
Copy link
Author

It seems this could be a problem of pathPrefix not being passed down to the gatsby-plugin-catch-links.

Is there a way to overwrite the plugin and use it in our main project instead?

@TylerBarnes
Copy link
Collaborator

@henrikwirth you should be able to add gatsby-plugin-catch-links to your gatsby-config.js and it'll use that instead.

@TylerBarnes
Copy link
Collaborator

I don't see an option for that in that plugin though, so this plugin may need to check for a path prefix and add it to the inline relative links

@TylerBarnes
Copy link
Collaborator

TylerBarnes commented Nov 23, 2020

Yep, looks like this plugin (gatsby-source-wordpress-experimental) needs to handle this https://github.com/gatsbyjs/Gatsby/blob/master/packages/gatsby-plugin-catch-links/src/catch-links.js#L167

@TylerBarnes TylerBarnes added the good first issue Good for newcomers label Nov 24, 2020
@henrikwirth
Copy link
Author

So after playing around a little, I figured, that the problem mainly arises from the fact, that the links inside content are written as follows:

<a href="/some-internal-link/">Some Link</a>

The problem is that usually, if you would use GatsbyLink on a link like this, it would prefix the link automatically. This doesn't happen for the links inside Wysiwyg though, since the node process function only picks up links, that have the actual WordPress backend domain in front. Like:

<a href="https://wp-backend.com/some-internal-link/">Some Link</a>

I think it would be great to have that as an option. like add path prefix to relative urls inside content. And I believe this should even be the default behavior.

@TylerBarnes TylerBarnes added the topic: WordPress Related to Gatsby's integration with WordPress label Feb 5, 2021
@TylerBarnes
Copy link
Collaborator

I'm cleaning up this repo a bit and moving this issue to our internal backlog. If anyone finds this issue and needs this sooner please add a feature request to https://portal.gatsbyjs.com/gatsby-cloud

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers topic: WordPress Related to Gatsby's integration with WordPress
Projects
None yet
Development

No branches or pull requests

2 participants