jekyll-linked-posts 0.4.3 → 0.5.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll/linked_posts.rb +36 -22
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92950b65f14da488097d32123c7cd808d4ec065e769c5c293605971f619896d0
4
- data.tar.gz: 7034eedcbec40cad8cb0a58e48a17bcc2a8459de9eeda1e16120e70cf0d35b80
3
+ metadata.gz: 7f93e87d40ed284d13bb31784c5b2d11684cca725444dd94d3cb9e264ce3b394
4
+ data.tar.gz: a2fbc7b95e5746b654ec59a32d73a30e693eb787955f3e9938b7a753c6c7661f
5
5
  SHA512:
6
- metadata.gz: a8a8cc4cd3be9185ca2621cebf844c5a527b3620debd115defdadac7605a9526a93d88ba707a1bf7ae58a548dc403a447357b90716a21e2396150f1a057cb799
7
- data.tar.gz: 381f32adb30858736f5b495c97aaee90b13855d97a04aba58de29d6f1609ca740b811355f0a8593270d59b58d67ca8e37404ee5022848d9403dc390338716499
6
+ metadata.gz: d955d83efd3a820eabb360c0c2472d77ec30fd143dafb982db43c479ecb2df7aed7e9d17edf1df43155dac6fe3f0951f2b25050458902c53b986d44655dac4a9
7
+ data.tar.gz: 5aedb476f2dc7e2c8d66a519279ec6c9904c9273b7c196d8cfb16b1b665c1794bcc61e74d7c560b62ba72e2bfaf85a5ccd4d6d4cbb0026c922ce8d1bb0245c52
@@ -20,32 +20,46 @@ module Jekyll
20
20
  # If it doesn't find anything it'll show a warning and replace the
21
21
  # value for nil.
22
22
  def read
23
- site.documents.each do |doc|
24
- fields.each do |field|
25
- next if (values = doc.data[field]).nil?
26
-
27
- # XXX: this lacks... elegance
28
- doc.data[field] =
29
- case values
30
- when String then find(values)
31
- when Array
32
- values.map do |doc|
33
- find doc
34
- end.compact
35
- when Hash
36
- values.map do |f, value|
37
- [f, v] if (v = find value)
38
- end.compact.to_h
39
- else
40
- Jekyll.logger.warn "Couldn't link posts on #{doc.relative_path}"
41
- nil
42
- end
43
- end
23
+ indexable_documents.each do |doc|
24
+ process doc
44
25
  end
45
26
  end
46
27
 
47
28
  private
48
29
 
30
+ # Processes fields from a document-like object
31
+ #
32
+ # @param :doc [Jekyll::Document,Jekyll::Page]
33
+ # @return [nil]
34
+ def process(doc)
35
+ fields.each do |field|
36
+ next if (values = doc.data[field]).nil?
37
+
38
+ # XXX: this lacks... elegance
39
+ doc.data[field] =
40
+ case values
41
+ when String then find(values)
42
+ when Array
43
+ values.map do |doc|
44
+ find doc
45
+ end.compact
46
+ when Hash
47
+ values.map do |f, value|
48
+ [f, v] if (v = find value)
49
+ end.compact.to_h
50
+ else
51
+ Jekyll.logger.warn "Couldn't link posts on #{doc.relative_path}"
52
+ nil
53
+ end
54
+ end
55
+
56
+ nil
57
+ end
58
+
59
+ def indexable_documents
60
+ @indexable_documents ||= site.documents + site.pages
61
+ end
62
+
49
63
  # The field to index posts by
50
64
  #
51
65
  # @return [String] by default uuid
@@ -59,7 +73,7 @@ module Jekyll
59
73
  #
60
74
  # @return [Hash]
61
75
  def indexed_documents
62
- @indexed_documents ||= site.documents.reduce({}) do |docs, doc|
76
+ @indexed_documents ||= indexable_documents.reduce({}) do |docs, doc|
63
77
  index_value = doc.data[indexed_field]
64
78
 
65
79
  unless index_value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-linked-posts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-30 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll