jekyll-uj-powertools 1.6.21 → 1.6.22

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: 74eea66888896dbfa05751e4f4f9764d0b228aa1362da0f7d286c2c139a531f6
4
- data.tar.gz: 1206892a9817ff204468c5508daddfe82fcca717001385aa9cd2884d4665a6c4
3
+ metadata.gz: f5e12576d7e500881fe56b9a6fdf6963b458635435ae7f27ef03df1562410c7a
4
+ data.tar.gz: 2418ef5a2771bb1383be22a27830beb6d9d513652f48eb2741204315eb2ec442
5
5
  SHA512:
6
- metadata.gz: feb77f22c66e6fefc1add8d5f7b9cae49374265b3527a93867f47a650906558b9423dc09a23ca837a251495d501abe54541e5dc35c965bd049cbcb79cc34ef0d
7
- data.tar.gz: 966dc5fe637bc9489da921b270b679df56106b9afe50e2919b359c6ee1377d82c7fde71504a1f764da007cb6747c12dd19467ae97226f2d020c2947dc7f651b3
6
+ metadata.gz: bde8bed7311f9b164d05608c4eef60984cb995598367f44ec05d8e46f21a6569692066a615e7f239f0f48dcdd92c693f660e508ab6e4b6b7dfdca945ffe67f45
7
+ data.tar.gz: 6b4ac3a7cb149197bad09eabacd25a8c2d05c899fede95e564464d37aa6e97e37de880e419269030419b8b44a46085bc88cecd0add0186e3125c1bb0d0ecee55
data/README.md CHANGED
@@ -70,6 +70,28 @@ Convert a string to title case.
70
70
  {{ "hello world" | uj_title_case }}
71
71
  ```
72
72
 
73
+ ### `uj_pluralize` Filter
74
+ Return the singular or plural form of a word based on a count.
75
+
76
+ ```liquid
77
+ {{ 1 | uj_pluralize: 'post', 'posts' }}
78
+ <!-- Output: post -->
79
+
80
+ {{ 5 | uj_pluralize: 'post', 'posts' }}
81
+ <!-- Output: posts -->
82
+
83
+ {{ 0 | uj_pluralize: 'item', 'items' }}
84
+ <!-- Output: items -->
85
+
86
+ <!-- Plural is optional - defaults to singular + 's' -->
87
+ {{ 3 | uj_pluralize: 'comment' }}
88
+ <!-- Output: comments -->
89
+
90
+ <!-- Works with irregular plurals -->
91
+ {{ 2 | uj_pluralize: 'child', 'children' }}
92
+ <!-- Output: children -->
93
+ ```
94
+
73
95
  ### `uj_commaify` Filter
74
96
  Format numbers with commas for better readability (e.g., 10000 becomes 10,000).
75
97
 
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
  # Gem info
7
7
  spec.name = "jekyll-uj-powertools"
8
- spec.version = "1.6.21"
8
+ spec.version = "1.6.22"
9
9
 
10
10
  # Author info
11
11
  spec.authors = ["ITW Creative Works"]
data/lib/filters/main.rb CHANGED
@@ -142,6 +142,21 @@ module Jekyll
142
142
  JSON.pretty_generate(input, indent: indent_string)
143
143
  end
144
144
 
145
+ # Pluralize a word based on a count
146
+ # Usage: {{ count | uj_pluralize: 'singular', 'plural' }}
147
+ # Example: {{ 5 | uj_pluralize: 'post', 'posts' }} => 'posts'
148
+ # Example: {{ 1 | uj_pluralize: 'post', 'posts' }} => 'post'
149
+ def uj_pluralize(count, singular, plural = nil)
150
+ # Default plural adds 's' to singular if not provided
151
+ plural ||= "#{singular}s"
152
+
153
+ # Convert count to integer for comparison
154
+ count_int = count.to_i
155
+
156
+ # Return singular for 1, plural for everything else (including 0)
157
+ count_int == 1 ? singular : plural
158
+ end
159
+
145
160
  # Format a number with commas (e.g., 10000 becomes 10,000)
146
161
  def uj_commaify(input)
147
162
  return input unless input
@@ -7,11 +7,17 @@ module Jekyll
7
7
  def initialize(site, base, category_name, category_slug)
8
8
  @site = site
9
9
  @base = base
10
- @dir = "blog/categories/#{category_slug}"
11
- @name = 'index.html'
10
+ @dir = "blog/categories"
11
+ @name = "#{category_slug}.html"
12
12
 
13
13
  self.process(@name)
14
- self.read_yaml(File.join(base, '_layouts'), 'blueprint/blog/categories/category.html')
14
+
15
+ # Initialize data without reading from file
16
+ self.data = {}
17
+ self.content = ''
18
+
19
+ # Set layout - Jekyll will resolve this through its layout chain
20
+ self.data['layout'] = 'blueprint/blog/categories/category'
15
21
 
16
22
  # Set page data
17
23
  self.data['category'] = {
@@ -19,10 +25,11 @@ module Jekyll
19
25
  'slug' => category_slug
20
26
  }
21
27
  self.data['title'] = "#{category_name} - Blog Categories"
22
- self.data['meta'] ||= {}
23
- self.data['meta']['title'] = "#{category_name} - Blog Categories - #{site.config['brand']['name'] || site.config['title']}"
24
- self.data['meta']['description'] = "Browse all blog posts in the #{category_name} category."
25
- self.data['meta']['breadcrumb'] = category_name
28
+ self.data['meta'] = {
29
+ 'title' => "#{category_name} - Blog Categories - #{site.config.dig('brand', 'name') || site.config['title'] || ''}",
30
+ 'description' => "Browse all blog posts in the #{category_name} category.",
31
+ 'breadcrumb' => category_name
32
+ }
26
33
  end
27
34
  end
28
35
 
@@ -30,11 +37,17 @@ module Jekyll
30
37
  def initialize(site, base, tag_name, tag_slug)
31
38
  @site = site
32
39
  @base = base
33
- @dir = "blog/tags/#{tag_slug}"
34
- @name = 'index.html'
40
+ @dir = "blog/tags"
41
+ @name = "#{tag_slug}.html"
35
42
 
36
43
  self.process(@name)
37
- self.read_yaml(File.join(base, '_layouts'), 'blueprint/blog/tags/tag.html')
44
+
45
+ # Initialize data without reading from file
46
+ self.data = {}
47
+ self.content = ''
48
+
49
+ # Set layout - Jekyll will resolve this through its layout chain
50
+ self.data['layout'] = 'blueprint/blog/tags/tag'
38
51
 
39
52
  # Set page data
40
53
  self.data['tag'] = {
@@ -42,10 +55,11 @@ module Jekyll
42
55
  'slug' => tag_slug
43
56
  }
44
57
  self.data['title'] = "#{tag_name} - Blog Tags"
45
- self.data['meta'] ||= {}
46
- self.data['meta']['title'] = "#{tag_name} - Blog Tags - #{site.config['brand']['name'] || site.config['title']}"
47
- self.data['meta']['description'] = "Browse all blog posts tagged with #{tag_name}."
48
- self.data['meta']['breadcrumb'] = tag_name
58
+ self.data['meta'] = {
59
+ 'title' => "#{tag_name} - Blog Tags - #{site.config.dig('brand', 'name') || site.config['title'] || ''}",
60
+ 'description' => "Browse all blog posts tagged with #{tag_name}.",
61
+ 'breadcrumb' => tag_name
62
+ }
49
63
  end
50
64
  end
51
65
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-uj-powertools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.21
4
+ version: 1.6.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-09 00:00:00.000000000 Z
11
+ date: 2025-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll