jekyll-uj-powertools 1.7.11 → 1.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b58316def5bdf1f88a2feb03a14b4c2857e5530eead4f39d246068fbf474cf94
4
- data.tar.gz: 0ef67cae823576783e197c3557d798420dc341784d3199d7ad8ec8a285f3cf29
3
+ metadata.gz: b5d3b0b5e6420c4de7821fe8f925fff59712eb31b9244feccf0291a42f2f7f9b
4
+ data.tar.gz: 38aae313ca04d6eb74c7248eebe7fbb2f7e1c00d5e8c21636d0683778f9233ab
5
5
  SHA512:
6
- metadata.gz: 0e7beb32662dc8dadb479c3f06a17b3c48f930dc09c1bf16a7bf56c826f41fdd1f96ab091b8a849a50aa0706eebeced5b11e91ebe139fd105f517a951eff6d3c
7
- data.tar.gz: 0b16685b292e37358bfa76721a71778a7b1a629ee6d03a94083aa0db5fae6b48044e89620c48741f2bea17073ccb3e6228b545084e944f908ab509bd391040e4
6
+ metadata.gz: b291387665a874e83e9dcc7e60db4f344ca26cab3c22d112a53412abb0f2ebe06c6fc917eb3e52ad08702367901f15e32aa1c113fd3d5f95b7ff09d7b2257ca4
7
+ data.tar.gz: 7178018a7fb28c365aaa354d0003020868c9f09f5f56b5c4f657b50ac8995ab72537a510393e6de11c02212064415222859db0839b5fcabcd452f97f86c4a58c
data/README.md CHANGED
@@ -106,6 +106,28 @@ Format numbers with commas for better readability (e.g., 10000 becomes 10,000).
106
106
  <!-- Output: 1,234.56 -->
107
107
  ```
108
108
 
109
+ ### `uj_append_param` Filter
110
+ Intelligently append a query parameter to a URL, using `?` or `&` depending on whether the URL already has a query string.
111
+
112
+ ```liquid
113
+ {{ "https://example.com/img.png" | uj_append_param: "cb", "123" }}
114
+ <!-- Output: https://example.com/img.png?cb=123 -->
115
+
116
+ {{ "https://example.com/img.png?w=200" | uj_append_param: "cb", "123" }}
117
+ <!-- Output: https://example.com/img.png?w=200&cb=123 -->
118
+ ```
119
+
120
+ ### `uj_cachebreak` Filter
121
+ Append a cache-busting query parameter (`cb=<timestamp>`) to any URL. Uses the same consistent timestamp as `site.uj.cache_breaker`. Handles URLs with or without existing query strings.
122
+
123
+ ```liquid
124
+ {{ site.brand.images.brandmark | uj_cachebreak }}
125
+ <!-- Output: https://cdn.example.com/logo.svg?cb=1234567890 -->
126
+
127
+ {{ "/assets/css/main.bundle.css" | uj_cachebreak }}
128
+ <!-- Output: /assets/css/main.bundle.css?cb=1234567890 -->
129
+ ```
130
+
109
131
  ### `uj_content_format` Filter
110
132
  Process content with Liquid templating and Markdown conversion, automatically transforming markdown and liquid into HTML intelligently based on the file type.
111
133
 
@@ -209,6 +231,8 @@ Resolves the site, layout, and page data into a single object, which can be usef
209
231
  {{ page.my.variable | default: layout.my.variable | default: site.my.variable }}
210
232
  ```
211
233
 
234
+ Merge order, lowest to highest priority: site config → layout chain (parents beat children) → front-matter `defaults:` from the site config → the page's own front matter. The `defaults:` layer lets a site override layout-provided content (e.g. framework sample sections) in one place without editing every page.
235
+
212
236
  ## Tags
213
237
  ### `iftruthy` Tag
214
238
  A custom Liquid tag that checks if a variable is truthy (not nil, not false, not empty string, not 0) and renders the content inside the tag if it is truthy.
@@ -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.7.11"
8
+ spec.version = "1.8.1"
9
9
 
10
10
  # Author info
11
11
  spec.authors = ["ITW Creative Works"]
data/lib/filters/main.rb CHANGED
@@ -149,6 +149,25 @@ module Jekyll
149
149
  JSON.pretty_generate(input, indent: indent_string)
150
150
  end
151
151
 
152
+ # Append a query parameter to a URL, handling existing query strings
153
+ # Usage: {{ "https://example.com/img.png" | uj_append_param: "cb", "123" }}
154
+ # => "https://example.com/img.png?cb=123"
155
+ # Usage: {{ "https://example.com/img.png?w=200" | uj_append_param: "cb", "123" }}
156
+ # => "https://example.com/img.png?w=200&cb=123"
157
+ def uj_append_param(input, key, value)
158
+ return input if input.nil? || input.to_s.strip.empty?
159
+ url = input.to_s.strip
160
+ sep = url.include?('?') ? '&' : '?'
161
+ "#{url}#{sep}#{key}=#{value}"
162
+ end
163
+
164
+ # Append a cache-busting query parameter to a URL
165
+ # Usage: {{ "https://example.com/img.png" | uj_cachebreak }}
166
+ # => "https://example.com/img.png?cb=1234567890"
167
+ def uj_cachebreak(input)
168
+ uj_append_param(input, 'cb', UJPowertools.cache_timestamp)
169
+ end
170
+
152
171
  # Pluralize a word based on a count
153
172
  # Usage: {{ count | uj_pluralize: 'singular', 'plural' }}
154
173
  # Example: {{ 5 | uj_pluralize: 'post', 'posts' }} => 'posts'
@@ -168,6 +168,17 @@ module Jekyll
168
168
  end
169
169
  end
170
170
 
171
+ # Merge front-matter defaults (site config `defaults:`) as their own layer.
172
+ # Jekyll materializes defaults into a Document's data at read time, but for
173
+ # Pages they only exist behind data.default_proc — resolved per-key on
174
+ # access, never during iteration — so the page-data merge below can't see
175
+ # them. Without this layer, site-wide `defaults:` values silently lose to
176
+ # layout front matter in `resolved`.
177
+ if site.respond_to?(:frontmatter_defaults) && item.respond_to?(:relative_path) && item.respond_to?(:type)
178
+ fm_defaults = site.frontmatter_defaults.all(item.relative_path, item.type)
179
+ resolved = deep_merge(resolved, filter_front_matter(fm_defaults)) unless fm_defaults.empty?
180
+ end
181
+
171
182
  # Finally merge page data (highest priority)
172
183
  # Filter out Jekyll internal properties
173
184
  page_data = filter_front_matter(item.data)
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.7.11
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works