keithmifsud / jekyll-target-blank

Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
MIT License
105 stars 19 forks source link

Define path on own domain as external links #47

Open tkrunning opened 5 years ago

tkrunning commented 5 years ago

Hi, your plugin looks like exactly what I've been looking for! However, I (and I know a lot of other people) are using a link structure that looks something like this for external links: mydomain.com/go/whatever or mydomain.com/out/whatever

This is for link tracking purposes.

The issue is that those links look like internal to your plugin, even though in reality they are external. Short of adding a custom class to all the links (which negates the purpose of your plugin) I don't think there's a way to define these as external, currently.

I took a quick look at your code to see if it would be easy to fix myself, but my Ruby skills are unfortunately very basic. Is this something that would be relatively straight forward to add?

keithmifsud commented 5 years ago

Hi, thank you for your feedback.

I understand what you need but no, this cannot be added without losing the main purpose of the plugin.

You can choose whether to add a CSS class to these links or code them manually.

Am I missing something? How can any program tell your tracking links from your internal links? Is there anything that distinguishes them?

tkrunning commented 5 years ago

It should be easy to distinguish them as all the external links start with /go (or whatever path a particular site uses, I think both /go and /out are quite common)

So in the plugin you'd just need the ability to set a path that is used for external redirects.

Do you understand what I mean?

keithmifsud commented 5 years ago

I understand. Thank you for clarifying.

This feature can be made possible with using a regexp in Jekyll's config.

I'm sorry that I don't have time to implement this at the moment. However, if you give it a go, I'll review your PR asap.

You can look at my code, the parts that change behaviour depending on CSS class names and work from there.

1) Describe the feature in the SPEC file. 2) Write code for the spec to pass. 3) Nudge the minor version number forward. 4) Submit PR 5) Fix and build issues. 6) I'll approve or comment on the PR. 7) I'll upload the Gem to RubyGems (asap).

Thank you once again.

PS: this was my first ever ruby code so I'm sure you can also do it :wink: