jekyll-uj-powertools 1.6.21 → 1.6.23

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: f8e4f51fc9ea4a48db55c09c67dc157e8ff10a2ac3ec70b0725cd691f22e8eeb
4
+ data.tar.gz: bd0025c8a7b871ce18e261c7b7a11d9eec2dfa756769905682eaecc681771d27
5
5
  SHA512:
6
- metadata.gz: feb77f22c66e6fefc1add8d5f7b9cae49374265b3527a93867f47a650906558b9423dc09a23ca837a251495d501abe54541e5dc35c965bd049cbcb79cc34ef0d
7
- data.tar.gz: 966dc5fe637bc9489da921b270b679df56106b9afe50e2919b359c6ee1377d82c7fde71504a1f764da007cb6747c12dd19467ae97226f2d020c2947dc7f651b3
6
+ metadata.gz: 265cb3b441bf454a72cb0dd80fd7357c8a775e91602969b8ed2f35068825baf3b48571fbbe7841ca801a694f17c2c7f2bb107a7c860af1c965e369448c4f6d2a
7
+ data.tar.gz: 60a90ebbfc3a02462063ade9848b1f58ed50596a525a6a1fd9d4547de89cb048dbd712e8b9f6dedfee86e1003365a021fc2a615a4a9938914c94d6901dc9e210
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.23"
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
 
data/lib/tags/logo.rb CHANGED
@@ -77,24 +77,60 @@ module Jekyll
77
77
  def load_logo_from_file(logo_name, type, color)
78
78
  # Create cache key
79
79
  cache_key = "#{type}/#{color}/#{logo_name}"
80
-
80
+
81
81
  # Return cached version if available
82
82
  return @@logo_cache[cache_key] if @@logo_cache.key?(cache_key)
83
-
83
+
84
84
  # Build file path
85
85
  logo_path = File.join(Dir.pwd, 'node_modules', 'ultimate-jekyll-manager', 'assets', 'logos', type, color, "#{logo_name}.svg")
86
-
86
+
87
87
  # Try to load the logo
88
88
  logo_svg = if File.exist?(logo_path)
89
89
  File.read(logo_path)
90
90
  else
91
91
  DEFAULT_LOGO
92
92
  end
93
-
93
+
94
+ # Prefix all IDs to prevent conflicts when multiple SVGs are on the same page
95
+ logo_svg = prefix_svg_ids(logo_svg, logo_name)
96
+
94
97
  # Cache the result
95
98
  @@logo_cache[cache_key] = logo_svg
96
99
  return logo_svg
97
100
  end
101
+
102
+ # Prefix all IDs in an SVG with the logo name to prevent conflicts
103
+ # when multiple SVGs are inlined on the same page
104
+ def prefix_svg_ids(svg_content, prefix)
105
+ # Find all id attributes in the SVG
106
+ ids = svg_content.scan(/\bid=["']([^"']+)["']/).flatten.uniq
107
+
108
+ return svg_content if ids.empty?
109
+
110
+ result = svg_content.dup
111
+
112
+ ids.each do |id|
113
+ new_id = "#{prefix}-#{id}"
114
+
115
+ # Replace id definitions: id="X" and id='X'
116
+ result.gsub!(/\bid=(["'])#{Regexp.escape(id)}\1/, "id=\"#{new_id}\"")
117
+
118
+ # Replace url() references: url(#X) and url('#X') and url("#X")
119
+ result.gsub!(/url\(\s*##{Regexp.escape(id)}\s*\)/, "url(##{new_id})")
120
+ result.gsub!(/url\(\s*["']##{Regexp.escape(id)}["']\s*\)/, "url(##{new_id})")
121
+
122
+ # Replace xlink:href references: xlink:href="#X"
123
+ result.gsub!(/xlink:href=["']##{Regexp.escape(id)}["']/, "xlink:href=\"##{new_id}\"")
124
+
125
+ # Replace x:href references (custom namespace, convert to standard href): x:href="#X"
126
+ result.gsub!(/x:href=["']##{Regexp.escape(id)}["']/, "href=\"##{new_id}\"")
127
+
128
+ # Replace href references (modern SVG): href="#X"
129
+ result.gsub!(/\bhref=["']##{Regexp.escape(id)}["']/, "href=\"##{new_id}\"")
130
+ end
131
+
132
+ result
133
+ end
98
134
  end
99
135
  end
100
136
 
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.23
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-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll