当前位置: 首页 > 软件库 > Web应用开发 > >

jekyll-target-blank

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 靳彦
操作系统 未知
开源组织
适用人群 未知
 软件概览

Jekyll Target Blank

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

Installation

Add the following to your site's Gemfile

gem 'jekyll-target-blank'

and add the following to your site's _config.yml

plugins:
  - jekyll-target-blank

Note: if jekyll --version is less than 3.5 use:

gems:
  - jekyll-target-blank

Usage

By default. all anchor tags and markdown links pointing to an external host, other than the one listed as the url in Jekyll's _config.yml will automatically be opened in a new browser tab once the site is generated.

All the links in pages, posts and custom collections are included except for __plain text links.

Examples

HTML

The following HTML anchor tag:

<a href="https://google.com">Google</a>

will be replaced with:

<a href="https://google.com" target="_blank" rel="noopener noreferrer">Google</a>

..unless your website's URL is google.com ��

Markdown

[Google](https://google.com)

will be generated as:

<a href="https://google.com" target="_blank" rel="noopener noreferrer">Google</a>

Configuration

No custom configuration is needed for using this plugin, however, you can override some default behaviours and also make use of some extra features as explained in this section.

Override the default behaviour

You can override the default behaviour and only force external links to open in new browser if they have a CSS class name included with the same value as the one listed in the Jekyll _config.yml file.

To override this automation, add an entry in your site's config.yml file, specifying which CSS class name a link must have for it to be forced to open in a new browser:

target-blank:
    css_class: ext-link

With the above setting, only links containing the class="ext-link" attribute will be forced to open in a new browser.

Automatically add additional CSS Classes

You can also automatically add additional CSS classes to qualifying external links. This feature is useful when you want to add CSS styling to external links such as automatically displaying an icon to show the reader that the link will open in a new browser.

You can add one or more space separated CSS classes in _config.yml like so:

target-blank:
    add_css_classes: css-class-one css-class-two

The above example will add class="css-class-one css-class-two" to the generated anchor tag. These CSS class names will be added in addition to any other existing CSS class names of a link.

Override the default rel attributes

For security reasons, rel="noopener noreferrer" are added by default to all the processed external links. You can override adding any of the noopener and noreferrer values with the following entries in your site's _config.yml file.

To exclude the noopener value:

target-blank:
   noopener: false

To exclude the noreferrer value:

target-blank:
   noreferrer: false

To exclude both noopner and noreferrer values:

target-blank:
   noopener: false
   noreferrer: false

Adding additional rel attribute values

You can add additional rel="" attribute values by simply specifying them in your site's _config.yml file.

target-blank:
    rel: nofollow

or even more than one extra:

target-blank:
    rel: nofollow

Note:

The rel setting overrides other default rel attribute values. Therefore, (for example), if you exclude the noopener value and then add it to the rel property, it will still be added. The following config:

target-blank:
    noopener: false
    rel: noopener

will output:

<a href"https://some-external-website.what" target="_blank" rel="noreferrer noopener">Some link</a>

Support

Simply create an issue and I will respond as soon as possible.

Contributing

  1. Fork it
  2. Create your feature branch (`git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Testing

rake spec
# or
rspec

Credits

The logo illustration was Designed by Freepik. Thank you ❤️

Legal

This software is distributed under the MIT license.

© 2018 - Keith Mifsud https://keith-mifsud.me and approved contributors.

  • MarkDown超链接写法:  行内式链接形式:[超链接文字](url) 而我们打开所生产的超链接,默认是在本窗口打开的,为了有更好的阅读体验,我们往往希望在新窗口 打开超链接,并不希望影响阅读本文。markdown目前应该还不支持这种语法的, 一、可以用jQuery 在合适的地方加上如下代码(更方便实用,推荐): <script type="text/javascript"> $(docume

 相关资料
  • 问题内容: 什么之间的区别,并和我应该使用如果我只是想打开一个新标签/窗口的链接? 问题答案: 根据HTML5规范: 一个 有效的浏览上下文名称 是至少一个字符的任何字符串,它不与U + 005F低线字符开头。(以下划线开头的名称保留用于特殊关键字。) 一个 有效的浏览上下文名称或关键字 是一个有效的浏览上下文名称的任何字符串或者是一个一个ASCII不区分大小写的匹配:_blank,_self,_

  • .target : Object 获取动画的目标对象。 myTween.target .target适用于TweenMaxTweenLite .target的参数 .target 示例 .box { width:50px; height:50px; border-radius:6px; margin-top:4px; display:inline-bloc

  • Attack Target This tab is used to configure the details of the target server for the attack. The required options are: Host - This is the IP address or hostname of the target server. Port - This is th

  • Burp Target tool The Target tool contains the site map, with detailed information about your target applications. It lets you define which targets are in scope for your current work, and also lets you

  • target.browser() returns: <Browser> 获取目标所属的浏览器。 target.browserContext() returns: <BrowserContext> 目标所属的浏览器上下文。 target.createCDPSession() returns: <Promise<CDPSession>> 创建一个 Chrome Devtools 协议会话至目标。 ta

  • Target Analyzer This function can be used to analyze a target web application and tell you how many static and dynamic URLs it contains, and how many parameters each URL takes. This can help you asses