jekyll_href 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad27b62f30c018e8bd18e64aff15c9db271b8c8052f76b96387711bcced86af7
4
- data.tar.gz: b0d7dc5ab8f04c8481762af18e1cc866680b7a24a4d3f87c0a0028e9e572e264
3
+ metadata.gz: d98dd353e927f8df1cf3832b2afefebb7be6dda942346cfaefb4899ec4de2606
4
+ data.tar.gz: 3bae16798938728a608f21161324d5843da1e0df1e210ac0e34cf894d5d29ed4
5
5
  SHA512:
6
- metadata.gz: 0325a5472644d4343a5fbd148413b9bb21b75ad81f03967d4605a979d346788a82c85096dee54025091ce94596ad608197ff4a37fd431c25d4f881881aa44c5e
7
- data.tar.gz: f783aee2b38d287ce135db43ad92bc90c549cee2f2e5d60b94cb2e5c4636f642df464b5722f4e0094a758f0292e713ca8584c36223bebd061e2d29fedea9edc3
6
+ metadata.gz: 27cc832e73c2eaf4db34dcb6cb67c026702ed9e106aa965d61a572cb44c0c4edcc0ca08ad0039c24e074734ecbce6f71643f6e049e76d6830ba64a548a35ed04
7
+ data.tar.gz: 819b74d3d7c6e1a6a6bc7d01797cccaa0c888dfcc7d3e8464b65c1d150bf5fa4dca349275e487163cf24ec38e7acaceae9d525a73f8eb5bf2676383cb85aa1a3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.0.9 / 2022-04-25
2
+ * Match now looks at all collections, not just posts
3
+
1
4
  ## 1.0.8 / 2022-04-11
2
5
  * Fixed match text
3
6
 
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).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllHrefVersion
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.9"
5
5
  end
data/lib/jekyll_href.rb CHANGED
@@ -125,17 +125,22 @@ class ExternalHref < Liquid::Tag
125
125
  site.posts[0].path = #{site.posts.docs[0].path}
126
126
  END_DEBUG
127
127
  }
128
- posts = site.posts.docs.select { |x| x.url.include? path }
129
- case posts.length
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
130
135
  when 0
131
136
  abort "href error: No url matches '#{@link}'" if die_if_nomatch
132
137
  @link = "#"
133
138
  @text = "<i>#{@link} is not available</i>"
134
139
  when 1
135
- @link = posts.first.url
140
+ @link = url_matches.first
136
141
  @link = "#{@link}\##{fragment}" if fragment
137
142
  else
138
- abort "Error: More than one url matched: #{ posts.map(&:relative_path).join(", ")}"
143
+ abort "Error: More than one url matched '#{path}': #{ url_matches.join(", ")}"
139
144
  end
140
145
  end
141
146
 
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.8
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 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll