jekyll-target-blank | Automatically opens external links in a new browser | Plugin library
kandi X-RAY | jekyll-target-blank Summary
kandi X-RAY | jekyll-target-blank Summary
Automatically adds a target="_blank" rel="noopener noreferrer" attribute to all external links in Jekyll's content plus several other automation features for the external links. Read more here.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of jekyll-target-blank
jekyll-target-blank Key Features
jekyll-target-blank Examples and Code Snippets
target-blank:
css_class: ext-link
target-blank:
add_css_classes: css-class-one css-class-two
target-blank:
noopener: false
target-blank:
noreferrer: false
target-blank:
noopener: false
noreferrer: false
target-blank:
rel:
gem 'jekyll-target-blank'
plugins:
- jekyll-target-blank
gems:
- jekyll-target-blank
Community Discussions
Trending Discussions on jekyll-target-blank
QUESTION
I've created a GitHubPage together with Jekyll, and currently I'm trying to use some of the basic plugins that are available. So far nothing fancy, I'm using the whitelisted plugins, specifically this one. It opens links in new tabs, which isn't supported by default in Markdown
.
So far, I've created the site using myusername.github.io
repo, cloned it to local, and created a basic site using jekyll new .
as is instructed here. Then I pushed all changes to GitHub and it's all working fine.
Then, to install the above mentioned plugin, I followed the steps mentioned in the help section, namely, these things:
...ANSWER
Answered 2018-Aug-23 at 05:10I'm the developer of Jekyll Target Blank. GH Pages only support some plugins https://help.github.com/articles/adding-jekyll-plugins-to-a-github-pages-site/. I have requested for this plugin to become supported but they their response was a maybe.
QUESTION
I am building a Jekyll ruby plugin that will replace the first occurrence of any word in the post copy text content with a hyperlink linking to the URL of a post by the same name.
The problems I'm havingI've gotten this to work but I can't figure out two problems in the process_words
method:
- How to only search for a post title in the main content copy text of the post, and not the meta tags before the post or the table of contents (which is also generated before main post copy text)? I can't get this to work with Nokigiri, even though that seems to be the tool of choice here.
- If a post's URL is not at
post.data['url']
, where is it? - Also, is there a more efficient, cleaner way to do this?
The current code works but will replace the first occurrence even if it's the value of an HTML attribute, like an anchor or a meta tag.
Example resultWe have a blog with 3 posts:
- Hobbies
- Food
- Bicycles
And in the "Hobbies" post body text, we have a sentence with each word appearing in it for the first time in the post, like so:
...ANSWER
Answered 2018-Jul-01 at 13:05this code looks very familiar :) I suggest you look into the Rspecs test file to test against your issues: https://github.com/keithmifsud/jekyll-target-blank
I'll try to answer your questions, sorry I couldn't test these myself the time of writing.
How to only search for a post title in the main content copy text of the post, and not the meta tags before the post or the table of contents (which is also generated before main post copy text)? I can't get this to work with Nokigiri, even though that seems to be the tool of choice here.
Your requirements here are:
1) Ignore content outside the tags.
This seems to already be implemented in the process_html()
method. This method is stating the only process the body_content
and it should work as it is. Have you got tests for it? How are you debugging it? The same string splitting works in my plugin. I.e. only content inside the body is processed.
2) Ignore content inside the Table of Contents (TOC).
I suggest you extend the process_html()
method by further splitting the body_content
variable. Search for content in between the opening and closing tags of your TOC (by id, css class etc..) and exclude it, then add it back in it's position before or after process_words
string.
3) Whether to use the Nokigiri plugin? This plugin is great for parsing html. I think you are parsing strings and then creating html. So vanilla Ruby and the URI plugin should suffice. You can still use it if you want but it won't be any faster then splitting strings in ruby.
If a post's URL is not at post.data['url'], where is it?
I think you should a have method to get all all post titles and then match the "words" against the array. You can get all the posts collection from the doc itself doc.site.posts
and foreach post return the title. The the process_words()
method can check each work to see if it matched an item from the array. But what if the title is made of more than one word?
Also, is there a more efficient, cleaner way to do this?
So far so good. I'll start with getting the issues fixed and then refactor for speed and coding standards.
Again I suggest you use testing to help you with this.
Let me know if I can help more :)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install jekyll-target-blank
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page