jekyll_href 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +3 -0
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +21 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d98dd353e927f8df1cf3832b2afefebb7be6dda942346cfaefb4899ec4de2606
|
4
|
+
data.tar.gz: 3bae16798938728a608f21161324d5843da1e0df1e210ac0e34cf894d5d29ed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27cc832e73c2eaf4db34dcb6cb67c026702ed9e106aa965d61a572cb44c0c4edcc0ca08ad0039c24e074734ecbce6f71643f6e049e76d6830ba64a548a35ed04
|
7
|
+
data.tar.gz: 819b74d3d7c6e1a6a6bc7d01797cccaa0c888dfcc7d3e8464b65c1d150bf5fa4dca349275e487163cf24ec38e7acaceae9d525a73f8eb5bf2676383cb85aa1a3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.0.9 / 2022-04-25
|
2
|
+
* Match now looks at all collections, not just posts
|
3
|
+
|
4
|
+
## 1.0.8 / 2022-04-11
|
5
|
+
* Fixed match text
|
6
|
+
|
7
|
+
## 1.0.7 / 2022-04-11
|
8
|
+
* Fixed bad reference when more than one URL matches
|
9
|
+
|
1
10
|
## 1.0.6 / 2022-04-05
|
2
11
|
* Updated to `jekyll_plugin_logger` v2.1.0
|
3
12
|
|
data/README.md
CHANGED
@@ -16,6 +16,9 @@ Also provides a convenient way to generate formatted and clickable URIs.
|
|
16
16
|
Note that the url should not be enclosed in quotes.
|
17
17
|
Also please note that the square brackets denote optional parameters, and should not be typed.
|
18
18
|
|
19
|
+
`match` will attempt to match the url fragment (specified as a regex) to a URL in any collection.
|
20
|
+
If multiple documents have matching URL an error is thrown.
|
21
|
+
|
19
22
|
|
20
23
|
### Additional Information
|
21
24
|
More information is available on my web site about [my Jekyll plugins](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.rb
CHANGED
@@ -58,11 +58,11 @@ class ExternalHref < Liquid::Tag
|
|
58
58
|
def initialize(tag_name, command_line, _parse_context)
|
59
59
|
super
|
60
60
|
|
61
|
+
@logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
61
62
|
@match = false
|
62
63
|
@tokens = command_line.strip.split
|
63
64
|
@follow = get_value("follow", " rel='nofollow'")
|
64
65
|
@target = get_value("notarget", " target='_blank'")
|
65
|
-
@logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
66
66
|
|
67
67
|
match_index = @tokens.index("match")
|
68
68
|
if match_index
|
@@ -118,31 +118,36 @@ class ExternalHref < Liquid::Tag
|
|
118
118
|
|
119
119
|
path, fragment = @link.split('#')
|
120
120
|
|
121
|
-
@logger.debug {
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
@logger.debug {
|
122
|
+
<<~END_DEBUG
|
123
|
+
@link=#{@link}
|
124
|
+
site.posts[0].url = #{site.posts.docs[0].url}
|
125
|
+
site.posts[0].path = #{site.posts.docs[0].path}
|
126
|
+
END_DEBUG
|
127
|
+
}
|
128
|
+
urls = site.collections
|
129
|
+
.values
|
130
|
+
.map { |x| x.class.method_defined?(:docs) ? x.docs : x }
|
131
|
+
.flatten
|
132
|
+
.map(&:url) # TODO Optimize this by caching the result
|
133
|
+
url_matches = urls.select { |url| url.include? path }
|
134
|
+
case url_matches.length
|
126
135
|
when 0
|
127
|
-
if die_if_nomatch
|
128
|
-
|
129
|
-
|
130
|
-
@link = "#"
|
131
|
-
@text = "<i>#{@link} is not available</i>"
|
132
|
-
end
|
136
|
+
abort "href error: No url matches '#{@link}'" if die_if_nomatch
|
137
|
+
@link = "#"
|
138
|
+
@text = "<i>#{@link} is not available</i>"
|
133
139
|
when 1
|
134
|
-
@link =
|
140
|
+
@link = url_matches.first
|
135
141
|
@link = "#{@link}\##{fragment}" if fragment
|
136
142
|
else
|
137
|
-
abort "Error: More than one url matched: #{
|
143
|
+
abort "Error: More than one url matched '#{path}': #{ url_matches.join(", ")}"
|
138
144
|
end
|
139
145
|
end
|
140
146
|
|
141
147
|
def replace_vars(context, link)
|
142
148
|
variables = context.registers[:site].config['plugin-vars']
|
143
149
|
variables.each do |name, value|
|
144
|
-
|
145
|
-
link = link.gsub("{{#{name}}}", value)
|
150
|
+
link = link.gsub "{{#{name}}}", value
|
146
151
|
end
|
147
152
|
link
|
148
153
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_href
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|