jekyll-uj-powertools 1.6.20 → 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 +4 -4
- data/README.md +22 -0
- data/jekyll-uj-powertools.gemspec +1 -1
- data/lib/filters/main.rb +15 -0
- data/lib/generators/blog-taxonomy.rb +125 -0
- data/lib/jekyll-uj-powertools.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5e12576d7e500881fe56b9a6fdf6963b458635435ae7f27ef03df1562410c7a
|
|
4
|
+
data.tar.gz: 2418ef5a2771bb1383be22a27830beb6d9d513652f48eb2741204315eb2ec442
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Blog Taxonomy Generator
|
|
2
|
+
# Generates category and tag pages for blog posts
|
|
3
|
+
# Reads from post.categories and post.tags (nested under 'post' frontmatter)
|
|
4
|
+
|
|
5
|
+
module Jekyll
|
|
6
|
+
class CategoryPage < Page
|
|
7
|
+
def initialize(site, base, category_name, category_slug)
|
|
8
|
+
@site = site
|
|
9
|
+
@base = base
|
|
10
|
+
@dir = "blog/categories"
|
|
11
|
+
@name = "#{category_slug}.html"
|
|
12
|
+
|
|
13
|
+
self.process(@name)
|
|
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'
|
|
21
|
+
|
|
22
|
+
# Set page data
|
|
23
|
+
self.data['category'] = {
|
|
24
|
+
'name' => category_name,
|
|
25
|
+
'slug' => category_slug
|
|
26
|
+
}
|
|
27
|
+
self.data['title'] = "#{category_name} - Blog Categories"
|
|
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
|
+
}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class TagPage < Page
|
|
37
|
+
def initialize(site, base, tag_name, tag_slug)
|
|
38
|
+
@site = site
|
|
39
|
+
@base = base
|
|
40
|
+
@dir = "blog/tags"
|
|
41
|
+
@name = "#{tag_slug}.html"
|
|
42
|
+
|
|
43
|
+
self.process(@name)
|
|
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'
|
|
51
|
+
|
|
52
|
+
# Set page data
|
|
53
|
+
self.data['tag'] = {
|
|
54
|
+
'name' => tag_name,
|
|
55
|
+
'slug' => tag_slug
|
|
56
|
+
}
|
|
57
|
+
self.data['title'] = "#{tag_name} - Blog Tags"
|
|
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
|
+
}
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class BlogTaxonomyGenerator < Generator
|
|
67
|
+
safe true
|
|
68
|
+
priority :normal
|
|
69
|
+
|
|
70
|
+
def generate(site)
|
|
71
|
+
# Collect unique categories and tags from posts
|
|
72
|
+
categories = {}
|
|
73
|
+
tags = {}
|
|
74
|
+
|
|
75
|
+
site.posts.docs.each do |post|
|
|
76
|
+
# Get categories from post.categories (nested under 'post' frontmatter)
|
|
77
|
+
post_data = post.data['post']
|
|
78
|
+
next unless post_data
|
|
79
|
+
|
|
80
|
+
# Process categories
|
|
81
|
+
if post_data['categories'].is_a?(Array)
|
|
82
|
+
post_data['categories'].each do |category|
|
|
83
|
+
next if category.nil? || category.to_s.strip.empty?
|
|
84
|
+
category_name = titleize(category.to_s.strip)
|
|
85
|
+
category_slug = slugify(category.to_s.strip)
|
|
86
|
+
categories[category_slug] = category_name
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Process tags
|
|
91
|
+
if post_data['tags'].is_a?(Array)
|
|
92
|
+
post_data['tags'].each do |tag|
|
|
93
|
+
next if tag.nil? || tag.to_s.strip.empty?
|
|
94
|
+
tag_name = titleize(tag.to_s.strip)
|
|
95
|
+
tag_slug = slugify(tag.to_s.strip)
|
|
96
|
+
tags[tag_slug] = tag_name
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Generate category pages
|
|
102
|
+
categories.each do |slug, name|
|
|
103
|
+
site.pages << CategoryPage.new(site, site.source, name, slug)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Generate tag pages
|
|
107
|
+
tags.each do |slug, name|
|
|
108
|
+
site.pages << TagPage.new(site, site.source, name, slug)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Log generation info
|
|
112
|
+
Jekyll.logger.info "BlogTaxonomy:", "Generated #{categories.size} category pages and #{tags.size} tag pages"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
def slugify(text)
|
|
118
|
+
text.downcase.gsub(/[^a-z0-9\s-]/, '').gsub(/\s+/, '-').gsub(/-+/, '-').strip
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def titleize(text)
|
|
122
|
+
text.split(/[\s_-]/).map(&:capitalize).join(' ')
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
data/lib/jekyll-uj-powertools.rb
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2025-12-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|
|
@@ -114,6 +114,7 @@ files:
|
|
|
114
114
|
- Rakefile
|
|
115
115
|
- jekyll-uj-powertools.gemspec
|
|
116
116
|
- lib/filters/main.rb
|
|
117
|
+
- lib/generators/blog-taxonomy.rb
|
|
117
118
|
- lib/generators/inject-properties.rb
|
|
118
119
|
- lib/helpers/variable_resolver.rb
|
|
119
120
|
- lib/hooks/inject-properties.rb
|