jekyll-link-attributes 0.0.3 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +9 -9
- data/Gemfile.lock +98 -95
- data/LICENSE +24 -24
- data/README.md +64 -50
- data/Rakefile +3 -3
- data/jekyll-link-attributes.gemspec +33 -33
- data/lib/jekyll-link-attributes/hooks.rb +18 -18
- data/lib/jekyll-link-attributes/version.rb +7 -7
- data/lib/jekyll-link-attributes.rb +56 -55
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed356ca2469b67757d91ce556bd251a74c77568a8e59df78566484ca905f23fc
|
4
|
+
data.tar.gz: 3de4e708cf72fc5f7bf6e0b59cbf0fa36d316858e67fe760e5997aa49d4b58e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbe5f18b8e6e205293abe1c6cdea0c793fa4badc5e7c362f848ae099c7d01d2999736f0540c9bec6e1f47d3e0c6f32f8bc52cd213f9998892a39565828723538
|
7
|
+
data.tar.gz: a7318d90c5a161b75bbf56591b635f78c40902ac2c0dec5d1e62511bc982d29e7fa41fdddd023992da2e91e34c9452ad80eea82b346a162052b724de2681cd3c
|
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
.idea
|
1
|
+
.idea
|
2
2
|
jekyll-link-attributes-*.gem
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0
|
1
|
+
3.1.0
|
data/Gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'rspec'
|
9
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem 'rspec'
|
9
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,95 +1,98 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
jekyll-link-attributes (0.0.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.8.1)
|
10
|
-
public_suffix (>= 2.0.2, < 6.0)
|
11
|
-
colorator (1.1.0)
|
12
|
-
concurrent-ruby (1.1.10)
|
13
|
-
diff-lcs (1.5.0)
|
14
|
-
em-websocket (0.5.3)
|
15
|
-
eventmachine (>= 0.12.9)
|
16
|
-
http_parser.rb (~> 0)
|
17
|
-
eventmachine (1.2.7)
|
18
|
-
ffi (1.15.5)
|
19
|
-
forwardable-extended (2.6.0)
|
20
|
-
http_parser.rb (0.8.0)
|
21
|
-
i18n (1.12.0)
|
22
|
-
concurrent-ruby (~> 1.0)
|
23
|
-
jekyll (4.2.2)
|
24
|
-
addressable (~> 2.4)
|
25
|
-
colorator (~> 1.0)
|
26
|
-
em-websocket (~> 0.5)
|
27
|
-
i18n (~> 1.0)
|
28
|
-
jekyll-sass-converter (~> 2.0)
|
29
|
-
jekyll-watch (~> 2.0)
|
30
|
-
kramdown (~> 2.3)
|
31
|
-
kramdown-parser-gfm (~> 1.0)
|
32
|
-
liquid (~> 4.0)
|
33
|
-
mercenary (~> 0.4.0)
|
34
|
-
pathutil (~> 0.9)
|
35
|
-
rouge (~> 3.0)
|
36
|
-
safe_yaml (~> 1.0)
|
37
|
-
terminal-table (~> 2.0)
|
38
|
-
jekyll-sass-converter (2.2.0)
|
39
|
-
sassc (> 2.0.1, < 3.0)
|
40
|
-
jekyll-watch (2.2.1)
|
41
|
-
listen (~> 3.0)
|
42
|
-
kramdown (2.4.0)
|
43
|
-
rexml
|
44
|
-
kramdown-parser-gfm (1.1.0)
|
45
|
-
kramdown (~> 2.0)
|
46
|
-
liquid (4.0.3)
|
47
|
-
listen (3.7.1)
|
48
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
49
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
50
|
-
mercenary (0.4.0)
|
51
|
-
nokogiri (1.13.8-x86_64-darwin)
|
52
|
-
racc (~> 1.4)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
rspec-
|
67
|
-
|
68
|
-
rspec-
|
69
|
-
rspec-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-link-attributes (0.0.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.8.1)
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
11
|
+
colorator (1.1.0)
|
12
|
+
concurrent-ruby (1.1.10)
|
13
|
+
diff-lcs (1.5.0)
|
14
|
+
em-websocket (0.5.3)
|
15
|
+
eventmachine (>= 0.12.9)
|
16
|
+
http_parser.rb (~> 0)
|
17
|
+
eventmachine (1.2.7)
|
18
|
+
ffi (1.15.5)
|
19
|
+
forwardable-extended (2.6.0)
|
20
|
+
http_parser.rb (0.8.0)
|
21
|
+
i18n (1.12.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
jekyll (4.2.2)
|
24
|
+
addressable (~> 2.4)
|
25
|
+
colorator (~> 1.0)
|
26
|
+
em-websocket (~> 0.5)
|
27
|
+
i18n (~> 1.0)
|
28
|
+
jekyll-sass-converter (~> 2.0)
|
29
|
+
jekyll-watch (~> 2.0)
|
30
|
+
kramdown (~> 2.3)
|
31
|
+
kramdown-parser-gfm (~> 1.0)
|
32
|
+
liquid (~> 4.0)
|
33
|
+
mercenary (~> 0.4.0)
|
34
|
+
pathutil (~> 0.9)
|
35
|
+
rouge (~> 3.0)
|
36
|
+
safe_yaml (~> 1.0)
|
37
|
+
terminal-table (~> 2.0)
|
38
|
+
jekyll-sass-converter (2.2.0)
|
39
|
+
sassc (> 2.0.1, < 3.0)
|
40
|
+
jekyll-watch (2.2.1)
|
41
|
+
listen (~> 3.0)
|
42
|
+
kramdown (2.4.0)
|
43
|
+
rexml
|
44
|
+
kramdown-parser-gfm (1.1.0)
|
45
|
+
kramdown (~> 2.0)
|
46
|
+
liquid (4.0.3)
|
47
|
+
listen (3.7.1)
|
48
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
49
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
50
|
+
mercenary (0.4.0)
|
51
|
+
nokogiri (1.13.8-x86_64-darwin)
|
52
|
+
racc (~> 1.4)
|
53
|
+
nokogiri (1.13.8-x86_64-linux)
|
54
|
+
racc (~> 1.4)
|
55
|
+
pathutil (0.16.2)
|
56
|
+
forwardable-extended (~> 2.6)
|
57
|
+
public_suffix (5.0.0)
|
58
|
+
racc (1.6.0)
|
59
|
+
rake (10.5.0)
|
60
|
+
rb-fsevent (0.11.2)
|
61
|
+
rb-inotify (0.10.1)
|
62
|
+
ffi (~> 1.0)
|
63
|
+
rexml (3.2.5)
|
64
|
+
rouge (3.30.0)
|
65
|
+
rspec (3.11.0)
|
66
|
+
rspec-core (~> 3.11.0)
|
67
|
+
rspec-expectations (~> 3.11.0)
|
68
|
+
rspec-mocks (~> 3.11.0)
|
69
|
+
rspec-core (3.11.0)
|
70
|
+
rspec-support (~> 3.11.0)
|
71
|
+
rspec-expectations (3.11.0)
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
+
rspec-support (~> 3.11.0)
|
74
|
+
rspec-mocks (3.11.1)
|
75
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
+
rspec-support (~> 3.11.0)
|
77
|
+
rspec-support (3.11.0)
|
78
|
+
safe_yaml (1.0.5)
|
79
|
+
sassc (2.4.0)
|
80
|
+
ffi (~> 1.9)
|
81
|
+
terminal-table (2.0.0)
|
82
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
83
|
+
unicode-display_width (1.8.0)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
x86_64-darwin-20
|
87
|
+
x86_64-linux
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
bundler (>= 2.0.0)
|
91
|
+
jekyll (>= 4.0.0)
|
92
|
+
jekyll-link-attributes!
|
93
|
+
nokogiri (>= 1.0.0)
|
94
|
+
rake (>= 10.0.0)
|
95
|
+
rspec
|
96
|
+
|
97
|
+
BUNDLED WITH
|
98
|
+
2.3.21
|
data/LICENSE
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
Copyright 2022 Twin Sun, LLC
|
2
|
-
|
3
|
-
Redistribution and use in source and binary forms, with or without modification,
|
4
|
-
are permitted provided that the following conditions are met:
|
5
|
-
|
6
|
-
* Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
8
|
-
* Redistributions in binary form must reproduce the above
|
9
|
-
copyright notice, this list of conditions and the following
|
10
|
-
disclaimer in the documentation and/or other materials provided
|
11
|
-
with the distribution.
|
12
|
-
* Neither the name of Twin Sun, LLC nor the names of its
|
13
|
-
contributors may be used to endorse or promote products derived
|
14
|
-
from this software without specific prior written permission.
|
15
|
-
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
20
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
1
|
+
Copyright 2022 Twin Sun, LLC
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
4
|
+
are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above
|
9
|
+
copyright notice, this list of conditions and the following
|
10
|
+
disclaimer in the documentation and/or other materials provided
|
11
|
+
with the distribution.
|
12
|
+
* Neither the name of Twin Sun, LLC nor the names of its
|
13
|
+
contributors may be used to endorse or promote products derived
|
14
|
+
from this software without specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
20
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
25
25
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,50 +1,64 @@
|
|
1
|
-
# Jekyll Link Attributes
|
2
|
-
|
3
|
-
This plugin adds `rel` and `target` attributes to all external links in your Jekyll site.
|
4
|
-
The default configuration opens external links in a new tab and conserves domain authority for your site.
|
5
|
-
|
6
|
-
## Setup
|
7
|
-
|
8
|
-
1. Add the gem to your `Gemfile`:
|
9
|
-
```ruby
|
10
|
-
gem 'jekyll-link-attributes'
|
11
|
-
```
|
12
|
-
2. Run `bundle install` to install the gem
|
13
|
-
3. Add the following to your `_config.yml`:
|
14
|
-
```yaml
|
15
|
-
plugins:
|
16
|
-
- jekyll-link-attributes
|
17
|
-
```
|
18
|
-
|
19
|
-
##
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- https://
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| `external_links.
|
40
|
-
| `external_links.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
1
|
+
# Jekyll Link Attributes
|
2
|
+
|
3
|
+
This plugin adds `rel` and `target` attributes to all external links in your Jekyll site.
|
4
|
+
The default configuration opens external links in a new tab and conserves domain authority for your site.
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
1. Add the gem to your `Gemfile`:
|
9
|
+
```ruby
|
10
|
+
gem 'jekyll-link-attributes'
|
11
|
+
```
|
12
|
+
2. Run `bundle install` to install the gem
|
13
|
+
3. Add the following to your `_config.yml`:
|
14
|
+
```yaml
|
15
|
+
plugins:
|
16
|
+
- jekyll-link-attributes
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Configuration
|
22
|
+
|
23
|
+
You can override the default configuration by adding the following section to your Jekyll site's `_config.yml`:
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
external_links:
|
27
|
+
enabled: true
|
28
|
+
rel: external nofollow noopener
|
29
|
+
target: _blank
|
30
|
+
exclude:
|
31
|
+
- https://example.com
|
32
|
+
- https://another.example.com/test.html
|
33
|
+
- https://regex.example.com/.+
|
34
|
+
```
|
35
|
+
|
36
|
+
#### Default Configuration
|
37
|
+
| Key | Default Value | Description |
|
38
|
+
| ---------------------------- | ---------------------------- | -------------------------------------------------- |
|
39
|
+
| `external_links.enabled` | `true` | Enable attribute modifications for external links. |
|
40
|
+
| `external_links.rel` | `external nofollow noopener` | The `rel` attribute to add to external links. |
|
41
|
+
| `external_links.target` | `_blank` | The `target` attribute to add to external links. |
|
42
|
+
| `external_links.exclude` | `[]` | A list of URLs to exclude from processing. |
|
43
|
+
|
44
|
+
|
45
|
+
### Skipping individual links
|
46
|
+
|
47
|
+
The `rel` or `target` attributes will not be modified for links that already have those existing attributes.
|
48
|
+
This allows you to skip individual links without having to modify the plugin's configuration.
|
49
|
+
|
50
|
+
```html
|
51
|
+
<a href"https://example.com" rel="nofollow">Example</a> <!-- `rel` will not be modified, but the configured `target` will be added. -->
|
52
|
+
<a href"https://example.com" target="_self">Example</a> <!-- `target` will not be modified, but the configured `rel` will be added. -->
|
53
|
+
<a href"https://example.com" rel="nofollow" target="_self">Example</a> <!-- Neither `rel` nor `target` will be modified. -->
|
54
|
+
```
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Pull requests are welcome!
|
59
|
+
If you wish to change existing behavior, please open an issue to discuss the change before investing time in a PR.
|
60
|
+
RSpec tests are encouraged for any new features.
|
61
|
+
|
62
|
+
## Supported by Twin Sun
|
63
|
+
|
64
|
+
This project is maintained by [Twin Sun](https://twinsunsolutions.com/), a custom mobile and web app development agency in Nashville, TN.
|
data/Rakefile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
@@ -1,33 +1,33 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'jekyll-link-attributes/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'jekyll-link-attributes'
|
7
|
-
spec.version = Jekyll::LinkAttributes::VERSION
|
8
|
-
spec.authors = ['twinsunllc']
|
9
|
-
spec.email = ['contact@twinsunsolutions.com']
|
10
|
-
|
11
|
-
spec.summary = 'This plugin adds `rel` and `target` attributes to all external links in your Jekyll site.'
|
12
|
-
spec.description = spec.summary
|
13
|
-
spec.homepage = 'https://github.com/twinsunllc/jekyll-link-attributes'
|
14
|
-
spec.license = 'BSD 3-Clause'
|
15
|
-
|
16
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
-
# delete this section to allow pushing this gem to any host.
|
18
|
-
if spec.respond_to?(:metadata)
|
19
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
-
else
|
21
|
-
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
-
end
|
23
|
-
|
24
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
spec.bindir = 'exe'
|
26
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = ['lib']
|
28
|
-
|
29
|
-
spec.add_development_dependency 'bundler', '>= 2.0.0'
|
30
|
-
spec.add_development_dependency 'jekyll', '>= 4.0.0'
|
31
|
-
spec.add_development_dependency 'nokogiri', '>= 1.0.0'
|
32
|
-
spec.add_development_dependency 'rake', '>= 10.0.0'
|
33
|
-
end
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'jekyll-link-attributes/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'jekyll-link-attributes'
|
7
|
+
spec.version = Jekyll::LinkAttributes::VERSION
|
8
|
+
spec.authors = ['twinsunllc']
|
9
|
+
spec.email = ['contact@twinsunsolutions.com']
|
10
|
+
|
11
|
+
spec.summary = 'This plugin adds `rel` and `target` attributes to all external links in your Jekyll site.'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/twinsunllc/jekyll-link-attributes'
|
14
|
+
spec.license = 'BSD 3-Clause'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
+
else
|
21
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '>= 2.0.0'
|
30
|
+
spec.add_development_dependency 'jekyll', '>= 4.0.0'
|
31
|
+
spec.add_development_dependency 'nokogiri', '>= 1.0.0'
|
32
|
+
spec.add_development_dependency 'rake', '>= 10.0.0'
|
33
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'jekyll/hooks'
|
4
|
-
require 'jekyll-link-attributes'
|
5
|
-
|
6
|
-
Jekyll::Hooks.register :documents, :post_render do |document|
|
7
|
-
Jekyll::LinkAttributes.post_render_html(document)
|
8
|
-
end
|
9
|
-
|
10
|
-
Jekyll::Hooks.register :pages, :post_render do |page|
|
11
|
-
next unless page.output_ext.eql?('.html')
|
12
|
-
|
13
|
-
Jekyll::LinkAttributes.post_render_html(page)
|
14
|
-
end
|
15
|
-
|
16
|
-
Jekyll::Hooks.register :posts, :post_render do |post|
|
17
|
-
Jekyll::LinkAttributes.post_render_html(post)
|
18
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll/hooks'
|
4
|
+
require 'jekyll-link-attributes'
|
5
|
+
|
6
|
+
Jekyll::Hooks.register :documents, :post_render do |document|
|
7
|
+
Jekyll::LinkAttributes.post_render_html(document)
|
8
|
+
end
|
9
|
+
|
10
|
+
Jekyll::Hooks.register :pages, :post_render do |page|
|
11
|
+
next unless page.output_ext.eql?('.html')
|
12
|
+
|
13
|
+
Jekyll::LinkAttributes.post_render_html(page)
|
14
|
+
end
|
15
|
+
|
16
|
+
Jekyll::Hooks.register :posts, :post_render do |post|
|
17
|
+
Jekyll::LinkAttributes.post_render_html(post)
|
18
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
class LinkAttributes
|
5
|
-
VERSION = '
|
6
|
-
end
|
7
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class LinkAttributes
|
5
|
+
VERSION = '1.0.1'
|
6
|
+
end
|
7
|
+
end
|
@@ -1,55 +1,56 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'jekyll-link-attributes/hooks'
|
4
|
-
require 'jekyll-link-attributes/version'
|
5
|
-
require 'nokogiri'
|
6
|
-
|
7
|
-
module Jekyll
|
8
|
-
|
9
|
-
# Adjusts external links in HTML documents.
|
10
|
-
class LinkAttributes
|
11
|
-
|
12
|
-
# Perform post_render processing on the specified document/page/post
|
13
|
-
# @param [Object] article a Jekyll document, page, or post
|
14
|
-
def self.post_render_html(article)
|
15
|
-
config = article.site.config
|
16
|
-
return unless external_links_enabled?(config: config)
|
17
|
-
|
18
|
-
output = Nokogiri::HTML(article.output)
|
19
|
-
output.css('a').each do |a|
|
20
|
-
next unless external_link?(config: config, url: a['href'])
|
21
|
-
next if excludes_external_link?(config: config, url: a['href'])
|
22
|
-
|
23
|
-
|
24
|
-
a['
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
excludes
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
enabled.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll-link-attributes/hooks'
|
4
|
+
require 'jekyll-link-attributes/version'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
|
9
|
+
# Adjusts external links in HTML documents.
|
10
|
+
class LinkAttributes
|
11
|
+
|
12
|
+
# Perform post_render processing on the specified document/page/post
|
13
|
+
# @param [Object] article a Jekyll document, page, or post
|
14
|
+
def self.post_render_html(article)
|
15
|
+
config = article.site.config
|
16
|
+
return unless external_links_enabled?(config: config)
|
17
|
+
|
18
|
+
output = Nokogiri::HTML(article.output)
|
19
|
+
output.css('a').each do |a|
|
20
|
+
next unless external_link?(config: config, url: a['href'])
|
21
|
+
next if excludes_external_link?(config: config, url: a['href'])
|
22
|
+
|
23
|
+
# only set rel and target if they're not already set
|
24
|
+
a['rel'] = external_link_rel(config: config) unless a['rel']
|
25
|
+
a['target'] = external_link_target(config: config) unless a['target']
|
26
|
+
end
|
27
|
+
|
28
|
+
article.output = output.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.excludes_external_link?(config:, url:)
|
34
|
+
excludes = (config.dig('external_links', 'exclude') || [])
|
35
|
+
excludes.any? { |exclude| Regexp.new("^#{exclude}$").match? url }
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.external_link?(config:, url:)
|
39
|
+
site_url = config['url']
|
40
|
+
!(url =~ %r{^https?://}).nil? && (site_url.nil? || !url.start_with?(site_url))
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.external_links_enabled?(config:)
|
44
|
+
enabled = config.dig('external_links', 'enabled')
|
45
|
+
enabled.nil? || enabled
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.external_link_rel(config:)
|
49
|
+
config.dig('external_links', 'rel') || 'external nofollow noopener'
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.external_link_target(config:)
|
53
|
+
config.dig('external_links', 'target') || '_blank'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-link-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- twinsunllc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,7 +90,7 @@ licenses:
|
|
90
90
|
- BSD 3-Clause
|
91
91
|
metadata:
|
92
92
|
allowed_push_host: https://rubygems.org
|
93
|
-
post_install_message:
|
93
|
+
post_install_message:
|
94
94
|
rdoc_options: []
|
95
95
|
require_paths:
|
96
96
|
- lib
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubygems_version: 3.3.3
|
109
|
-
signing_key:
|
109
|
+
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: This plugin adds `rel` and `target` attributes to all external links in your
|
112
112
|
Jekyll site.
|