jekyll-uj-powertools 1.7.7 → 1.7.9
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 +1 -0
- data/jekyll-uj-powertools.gemspec +1 -1
- data/lib/hooks/markdown-images.rb +20 -9
- data/lib/tags/icon.rb +3 -2
- data/lib/tags/iffile.rb +24 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8946df06f9ff9ff4de4bbb7566928462e64736badf6a6900d817d2312cd39c85
|
|
4
|
+
data.tar.gz: 871c60f06351aad8001c10f93febe0aafb6f5a2b3d488e4a0befc966efe68f32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: caa39030a002f773855dc36f8617188d42d429a7c31ff9bf7ad41a86c60a31b0dc2258581990a9c577aad9521028e7c511db639500554111997ffb7d23f530bf
|
|
7
|
+
data.tar.gz: '05308773511835643c641184e7960634e4e9858977161f8e574c8e835a2cccfc213884321c655acf4b66c189a37053fe554d99bd8377d0edccc112eb850cf0c9'
|
data/README.md
CHANGED
|
@@ -231,6 +231,7 @@ A custom Liquid tag that renders a Font Awesome icon with the specified style an
|
|
|
231
231
|
```liquid
|
|
232
232
|
{% uj_icon "rocket", "fa-lg me-2" %}
|
|
233
233
|
```
|
|
234
|
+
The rendered `<i>` element includes a `data-icon` attribute set to the resolved icon name (e.g. `<i class="fa fa-lg me-2" data-icon="rocket">...</i>`), making it easy to target specific icons in CSS or JS via `[data-icon="rocket"]`.
|
|
234
235
|
|
|
235
236
|
### `uj_logo` Tag
|
|
236
237
|
A custom Liquid tag that renders company logos from the Ultimate Jekyll Manager assets. It supports brandmarks and combomarks in various colors.
|
|
@@ -18,11 +18,8 @@ module Jekyll
|
|
|
18
18
|
# Get post ID for @post/ prefix resolution
|
|
19
19
|
post_id = doc.data['post'] && doc.data['post']['id'] ? doc.data['post']['id'] : nil
|
|
20
20
|
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
alt_text = $1
|
|
24
|
-
image_path = $2
|
|
25
|
-
|
|
21
|
+
# Shared transformer: convert  → rendered <img> HTML
|
|
22
|
+
render_image = lambda do |alt_text, image_path|
|
|
26
23
|
# Resolve @post/ prefix to full blog image path
|
|
27
24
|
if image_path.start_with?('@post/')
|
|
28
25
|
if post_id
|
|
@@ -33,19 +30,33 @@ module Jekyll
|
|
|
33
30
|
end
|
|
34
31
|
end
|
|
35
32
|
|
|
36
|
-
# Build the Liquid tag string
|
|
37
33
|
if image_class
|
|
38
34
|
liquid_tag = "{% uj_image \"#{image_path}\", alt=\"#{alt_text}\", class=\"#{image_class}\" %}"
|
|
39
35
|
else
|
|
40
36
|
liquid_tag = "{% uj_image \"#{image_path}\", alt=\"#{alt_text}\" %}"
|
|
41
37
|
end
|
|
42
38
|
|
|
43
|
-
# Parse and render the Liquid template immediately
|
|
44
39
|
template = Liquid::Template.parse(liquid_tag)
|
|
45
40
|
context = doc.site.site_payload.merge({'page' => doc.to_liquid})
|
|
46
|
-
|
|
41
|
+
template.render(Liquid::Context.new(context))
|
|
42
|
+
end
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
# First pass: linked images [](href) → <a href><img></a>
|
|
45
|
+
# Must run BEFORE the bare-image pass so the outer [](href) wrapper is preserved.
|
|
46
|
+
# Kramdown otherwise promotes the inner  to a block and discards the wrapping link.
|
|
47
|
+
# display:block on the anchor — otherwise an inline <a> has a 20px-tall hit
|
|
48
|
+
# box, and clicks on the (taller) image overflow miss the link entirely.
|
|
49
|
+
doc.content = doc.content.gsub(/\[!\[([^\]]*)\]\(([^)]+)\)\]\(([^)]+)\)/) do
|
|
50
|
+
alt_text = $1
|
|
51
|
+
image_path = $2
|
|
52
|
+
href = $3
|
|
53
|
+
img_html = render_image.call(alt_text, image_path)
|
|
54
|
+
"\n\n<a href=\"#{href}\" style=\"display:block\">#{img_html}</a>\n\n"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Second pass: bare markdown images 
|
|
58
|
+
doc.content = doc.content.gsub(/!\[([^\]]*)\]\(([^)]+)\)/) do
|
|
59
|
+
result = render_image.call($1, $2)
|
|
49
60
|
"\n\n#{result}\n\n"
|
|
50
61
|
end
|
|
51
62
|
end
|
data/lib/tags/icon.rb
CHANGED
|
@@ -110,10 +110,11 @@ module Jekyll
|
|
|
110
110
|
# end
|
|
111
111
|
|
|
112
112
|
# Wrap in i tag with CSS classes (always include 'fa' class)
|
|
113
|
+
data_attr = " data-icon=\"#{icon_name}\"" if icon_name && !icon_name.empty?
|
|
113
114
|
if css_classes && !css_classes.empty?
|
|
114
|
-
"<i class=\"fa #{css_classes}\">#{processed_svg}</i>"
|
|
115
|
+
"<i class=\"fa #{css_classes}\"#{data_attr}>#{processed_svg}</i>"
|
|
115
116
|
else
|
|
116
|
-
"<i class=\"fa\">#{processed_svg}</i>"
|
|
117
|
+
"<i class=\"fa\"#{data_attr}>#{processed_svg}</i>"
|
|
117
118
|
end
|
|
118
119
|
end
|
|
119
120
|
|
data/lib/tags/iffile.rb
CHANGED
|
@@ -16,11 +16,10 @@ module Jekyll
|
|
|
16
16
|
# Get the site object
|
|
17
17
|
site = context.registers[:site]
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
path = resolve_path(context)
|
|
20
|
+
|
|
22
21
|
# Return empty if path couldn't be resolved
|
|
23
|
-
return ""
|
|
22
|
+
return "" if path.nil? || path.to_s.empty?
|
|
24
23
|
|
|
25
24
|
# Ensure path starts with /
|
|
26
25
|
path = "/#{path}" unless path.to_s.start_with?('/')
|
|
@@ -39,6 +38,27 @@ module Jekyll
|
|
|
39
38
|
""
|
|
40
39
|
end
|
|
41
40
|
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
# Resolve the path argument from context.
|
|
45
|
+
# Quoted strings are literals. Bare tokens are looked up as variables;
|
|
46
|
+
# if the root segment isn't defined in context, fall back to the literal markup.
|
|
47
|
+
def resolve_path(context)
|
|
48
|
+
return nil if @path.nil? || @path.empty?
|
|
49
|
+
|
|
50
|
+
# Quoted string literal
|
|
51
|
+
if @path.match(/^["'](.*)["']$/)
|
|
52
|
+
return $1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
root = @path.split('.').first
|
|
56
|
+
resolved = resolve_variable(context, @path)
|
|
57
|
+
return resolved unless resolved.nil?
|
|
58
|
+
|
|
59
|
+
# Variable resolved to nil — fall back to literal only if root is also nil/undefined
|
|
60
|
+
context[root].nil? ? @path : nil
|
|
61
|
+
end
|
|
42
62
|
end
|
|
43
63
|
end
|
|
44
64
|
end
|