jekyll-uj-powertools 1.6.4 → 1.6.6
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/jekyll-uj-powertools.gemspec +1 -1
- data/lib/jekyll-uj-powertools.rb +1 -0
- data/lib/tags/urlmatch.rb +61 -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: 608cc68c81696c6099554e6d4d54ab585c04e4add723321b974e90f2788c2b32
|
4
|
+
data.tar.gz: 67e68ad2c9a807409ca6a0af0fe8cdd85582fc478a31d0714c9eaccdd97b0317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ccd2a2a777435e42d65527f60be6828052e89e041bde5bf35f3c228295908a578b51bd364c29f6bf0dd51223989e6a91ab4081a29b880e29ef7aded1869c41
|
7
|
+
data.tar.gz: 4110821b512057be2ec78d1bce933b6d06bab45ea0558e3c33c8de0c403b7ddb33efa548884c78500cd24d52783338acef9f71ce0c1dd887f12bb30b0ca776d6
|
data/lib/jekyll-uj-powertools.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Libraries
|
2
|
+
require_relative '../helpers/variable_resolver'
|
3
|
+
|
4
|
+
# Tag
|
5
|
+
module Jekyll
|
6
|
+
module UJPowertools
|
7
|
+
class UrlMatchTag < Liquid::Tag
|
8
|
+
include VariableResolver
|
9
|
+
|
10
|
+
def initialize(tag_name, markup, tokens)
|
11
|
+
super
|
12
|
+
# Parse arguments: url, output_if_active
|
13
|
+
args = parse_arguments(markup)
|
14
|
+
@url = args[0] || ''
|
15
|
+
@output = args[1] || 'active'
|
16
|
+
end
|
17
|
+
|
18
|
+
def render(context)
|
19
|
+
# Get the current page URL
|
20
|
+
page_url = context['page']['url']
|
21
|
+
|
22
|
+
# Resolve the URL to check (handles both literals and variables)
|
23
|
+
check_url = resolve_input(context, @url, true)
|
24
|
+
|
25
|
+
# Resolve the output (handles both literals and variables)
|
26
|
+
output = resolve_input(context, @output, true)
|
27
|
+
|
28
|
+
# Normalize URLs to handle index pages
|
29
|
+
# /about/index.html becomes /about/
|
30
|
+
# / stays as /
|
31
|
+
normalized_page_url = normalize_url(page_url)
|
32
|
+
normalized_check_url = normalize_url(check_url)
|
33
|
+
|
34
|
+
# Return output if URLs match, empty string otherwise
|
35
|
+
if normalized_page_url == normalized_check_url
|
36
|
+
output
|
37
|
+
else
|
38
|
+
""
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def normalize_url(url)
|
45
|
+
return nil if url.nil?
|
46
|
+
|
47
|
+
# Remove index.html from the end
|
48
|
+
normalized = url.sub(/index\.html?$/, '')
|
49
|
+
|
50
|
+
# Ensure trailing slash for non-root paths
|
51
|
+
if normalized != '/' && !normalized.end_with?('/')
|
52
|
+
normalized += '/'
|
53
|
+
end
|
54
|
+
|
55
|
+
normalized
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Liquid::Template.register_tag('urlmatch', Jekyll::UJPowertools::UrlMatchTag)
|
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.6
|
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-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/tags/readtime.rb
|
133
133
|
- lib/tags/social.rb
|
134
134
|
- lib/tags/translation_url.rb
|
135
|
+
- lib/tags/urlmatch.rb
|
135
136
|
homepage: https://github.com/itw-creative-works/jekyll-uj-powertools
|
136
137
|
licenses:
|
137
138
|
- MIT
|