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

[gatsby-source-wordpress] Remove "Continue reading" links #8782

Closed
chmac opened this issue Oct 4, 2018 · 6 comments
Closed

[gatsby-source-wordpress] Remove "Continue reading" links #8782

chmac opened this issue Oct 4, 2018 · 6 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@chmac
Copy link
Contributor

chmac commented Oct 4, 2018

Summary

WordPress includes "Continue reading" links inside it's excerpt field. For example:

<p class=\"link-more\"><a href=\"https://wpdemo.gatsbycentral.com/2018/10/04/morbi-rhoncus-malesuada/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Morbi rhoncus malesuada&#8221;</span></a></p>\n

These links include the full URL of the WordPress site.

My suggestion is to remove this entire link. To strip out the entire <p class="link-more" tag.

Motivation

WordPress in this case is a source of content, not a frontend. The mixture of links between them both is confusing. It's possible to hack around this problem inside Gatsby, but that requires changes from the user. There is almost no scenario in which an <a href=... to the WordPress site is a good idea.

EDIT: Forgot to say, I'm happy to work on this and file a PR, just wanted to check in before starting on it to see if it's a well supported idea or not.

@TylerBarnes
Copy link
Contributor

TylerBarnes commented Oct 7, 2018

I think this isn't such a good idea since there may end up being many other places like this. Little workarounds in each case is going end up being painful. I think the better solution is to use the search and replace content urls option from the source plugin to just remove it entirely and make it a relative link in every case everwhere:

        searchAndReplaceContentUrls: {
          sourceUrl: 'https://wordpressurl.com/',
          replacementUrl: '/',
        },

Then use wordpress to build your site structure from each pages link. In gatsby node instead of using the slug of the page to create the page you can use the link since it's just a path now.

There is another big benefit to doing it this way which is that you can now easily use wordpress menus as actual menus since all the pages in wordpress and gatsby have the exact same url.

At that point, all routing will be setup in wordpress. Even the frontpage setting will work.

@chmac
Copy link
Contributor Author

chmac commented Oct 8, 2018

@TylerBarnes Good feedback, you're right, specifically removing that exact <p doesn't make sense. I'd favour a more generic set of search and replace pairs. I tried the approach you mentioned of changing the domain, but I found that many other things were broken by this. For example some <img tags.

I think being able to perform arbitrary transformations on all content from WordPress would be super useful. In fact, come to think of it, it could be a super useful plugin to apply arbitrary transformations on any imported data. Not sure what's involved in creating such a plugin though.

Would a PR that adds a searchAndReplaceContent argument which takes an array of search patterns and replace values be welcome as a PR?

@TylerBarnes
Copy link
Contributor

Hmm, yes I guess that would break images. Seems like a more advanced search/replace could be warranted, I'm not really sure who maintains the wordpress source plugin and who would make that call.

@gatsbot
Copy link

gatsbot bot commented Jan 20, 2019

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 20, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 1, 2019

Hey again!

It’s been 30 since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Feb 1, 2019
@TylerBarnes
Copy link
Contributor

@chmac if you're interested I ended up making my own gatsby wordpress source plugin! It adds a ton of features that gatsby-source-wordpress doesn't have like live instant previews, menu support, gatsby-image for images in WP wysiwyg areas, "instant" build times with live data during a build, and more. I haven't yet added the exact feature in this issue but this would be super easy to solve with the way I've set everything up. I know the gatsby guys are super busy making gatsby awesome and they don't build WP sites so I'm trying to fill in the gaps that are missing for WP devs https://github.com/TylerBarnes/wordsby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

2 participants