jekyll-uj-powertools 1.0.19 → 1.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 308a3981411553ab6ee7b5545e21b7a5490ffb80c347aa32155555e557ba3e16
4
- data.tar.gz: 29085f0a511bfc4f6a9253f611ceec258a1ccd62addb1b79082d1c0ca95278eb
3
+ metadata.gz: 9def945807a007c5f07c2cad6de148474a59d90af700a01eb745fdb7d6bb064e
4
+ data.tar.gz: 2ddbc8d42fc0200d0672070a5f5d02601be48a5e337a29b309f3fbc1199cfa05
5
5
  SHA512:
6
- metadata.gz: f0d3c31e5dd9d81fc2d2fd916cec009e6cbeffe33076be8e3c7eba488ff0959dbd48e590f2c04baccc0972c98c1bd6358d0b8f532f568025bdde9116440cfc70
7
- data.tar.gz: 737700b737ec8c0c84936cdc2ccfd3cb5aee5820740628b9cb6d23f37f46552fbadf2394357a359b932e6a637d2a276c4939f02dc351b61c2484174caf35e810
6
+ metadata.gz: 22018d40543d7dbf37425ff7e1a70f62c201c4f010b1be2bdfcc18ffc78f7e512f5966089ce2e96a503472641555aa41a21ce3478ec3230b6894e8dad7a19e65
7
+ data.tar.gz: 4f7f568580213d6ee5d1b73aadd79d639083e767eec0b24ca4b131428eafd8b2eb7bb2a09b8c4a386da235362e8c4cabdb4f5f3e2e87c0c8440f0951ad44ef3b
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module UJPowertools
3
- VERSION = "1.0.19"
3
+ VERSION = "1.0.21"
4
4
  end
5
5
  end
@@ -49,25 +49,62 @@ module Jekyll
49
49
  end
50
50
  end
51
51
 
52
+ # class InjectData < Generator
53
+ # safe true
54
+ # priority :low
55
+
56
+ # def generate(site)
57
+ # site.pages.each do |page|
58
+ # # Inject a random number into the page's data
59
+ # page.data['random_number'] = rand(100) # Random number between 0 and 99
60
+
61
+ # next unless page.data['layout'] # Skip pages without layouts
62
+
63
+ # # Find the layout file by its name
64
+ # layout_name = page.data['layout']
65
+ # layout = site.layouts[layout_name]
66
+
67
+ # if layout && layout.data
68
+ # # Merge layout front matter into page's "layout_data"
69
+ # page.data['layout_data'] = layout.data
70
+ # end
71
+ # end
72
+ # end
73
+ # end
74
+
52
75
  class InjectData < Generator
53
76
  safe true
54
77
  priority :low
55
78
 
56
79
  def generate(site)
80
+ # Process pages
57
81
  site.pages.each do |page|
58
- # Inject a random number into the page's data
59
- page.data['random_number'] = rand(100) # Random number between 0 and 99
82
+ inject_data(page, site)
83
+ end
60
84
 
61
- next unless page.data['layout'] # Skip pages without layouts
85
+ # Process documents in all collections
86
+ site.collections.each do |_, collection|
87
+ collection.docs.each do |document|
88
+ inject_data(document, site)
89
+ end
90
+ end
91
+ end
62
92
 
63
- # Find the layout file by its name
64
- layout_name = page.data['layout']
65
- layout = site.layouts[layout_name]
93
+ private
66
94
 
67
- if layout && layout.data
68
- # Merge layout front matter into page's "layout_data"
69
- page.data['layout_data'] = layout.data
70
- end
95
+ def inject_data(item, site)
96
+ # Inject a random number into the item's data
97
+ item.data['random_id'] = rand(100) # Random number between 0 and 99
98
+
99
+ return unless item.data['layout'] # Skip items without layouts
100
+
101
+ # Find the layout file by its name
102
+ layout_name = item.data['layout']
103
+ layout = site.layouts[layout_name]
104
+
105
+ if layout && layout.data
106
+ # Merge layout front matter into item's "layout_data"
107
+ item.data['layout_data'] = layout.data
71
108
  end
72
109
  end
73
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-uj-powertools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works