sutty-liquid 0.3.0 → 0.4.0
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/lib/jekyll/drops/url_drop_decorator.rb +16 -0
- data/lib/jekyll/filters/menu.rb +54 -0
- data/lib/sutty-liquid.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5821ac5773831bb4da8ff820a9e37e52cbdda1eb6d4d02394806b3553521d199
|
|
4
|
+
data.tar.gz: 28fc6cadd2764f2c13d25a80464b2431b68c4bcb439dd8955b34fd7186943832
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f03097086f1ec6790b5476d0e138aaae5719968e5967e33481d6995ac3abac78f3ed5f7ce29822f5622ae8d00e66296d52ffecfda696a9b619efebc205f6214
|
|
7
|
+
data.tar.gz: 6c21db3c81ace646f82c244579f5452cdd18cb88ceb16ce9676d2026b3df85c24b41b4dc1d1834eea007feccb1208d0532c071806ec38c645b8858b90fc822e4
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'jekyll/drops/url_drop'
|
|
4
|
+
|
|
5
|
+
module Jekyll
|
|
6
|
+
module Drops
|
|
7
|
+
module UrlDropDecorator
|
|
8
|
+
# Permits to use layout as an URL placeholder
|
|
9
|
+
def layout
|
|
10
|
+
@obj.data['layout']
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Jekyll::Drops::UrlDrop.include Jekyll::Drops::UrlDropDecorator
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
module Filters
|
|
5
|
+
module Menu
|
|
6
|
+
# Verifies if the given URL is an active item on the menu.
|
|
7
|
+
#
|
|
8
|
+
# Example usage:
|
|
9
|
+
#
|
|
10
|
+
# {% assign active_url = page.url | menu_active %}
|
|
11
|
+
# {% for item in site.i18n.menu.items %}
|
|
12
|
+
# <a
|
|
13
|
+
# href="{{ item.href }}"
|
|
14
|
+
# class="{{ page.url | menu_active | equals: item.href | ternary: 'active', '' }}">
|
|
15
|
+
#
|
|
16
|
+
# {{ item.title }}
|
|
17
|
+
# </a>
|
|
18
|
+
# {% endfor %}
|
|
19
|
+
#
|
|
20
|
+
# @param [String] The URL to be verified
|
|
21
|
+
# @return [String] The item URL
|
|
22
|
+
def menu_active_item(page_url)
|
|
23
|
+
site_menu&.find do |key, value|
|
|
24
|
+
key == page_url || page_url.start_with?(key)
|
|
25
|
+
end&.last
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# The menu is defined in a data file that corresponds to the site
|
|
29
|
+
# language. This method converts the menu items into a map of URL
|
|
30
|
+
# parts and actual URLs.
|
|
31
|
+
#
|
|
32
|
+
# @see _data/es.yml
|
|
33
|
+
# @see {https://0xacab.org/sutty/jekyll/jekyll-locales}
|
|
34
|
+
# @return [Hash]
|
|
35
|
+
def site_menu
|
|
36
|
+
site = @context.registers[:site]
|
|
37
|
+
@site_menu ||= site.data.dig(site.config['locale'], 'menu', 'items')&.reduce({}) do |menu, item|
|
|
38
|
+
# Ignore empty or anchor items
|
|
39
|
+
next menu if item['href'].nil? || item['href'].empty? || item['href']&.start_with?('#')
|
|
40
|
+
|
|
41
|
+
menu[item['href']] = item['href']
|
|
42
|
+
|
|
43
|
+
item['active']&.each do |a|
|
|
44
|
+
menu[a] = item['href']
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
menu
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
Liquid::Template.register_filter(Jekyll::Filters::Menu)
|
data/lib/sutty-liquid.rb
CHANGED
|
@@ -6,9 +6,12 @@ require_relative 'jekyll/filters/date_local'
|
|
|
6
6
|
require_relative 'jekyll/filters/infinite'
|
|
7
7
|
require_relative 'jekyll/filters/file'
|
|
8
8
|
require_relative 'jekyll/filters/json'
|
|
9
|
+
require_relative 'jekyll/filters/menu'
|
|
9
10
|
require_relative 'jekyll/filters/number'
|
|
10
11
|
require_relative 'jekyll/filters/sample'
|
|
11
12
|
require_relative 'jekyll/filters/social_network'
|
|
12
13
|
|
|
13
14
|
require_relative 'jekyll/filters/pry'
|
|
14
15
|
require_relative 'jekyll/tags/pry'
|
|
16
|
+
|
|
17
|
+
require_relative 'jekyll/drops/url_drop_decorator'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sutty-liquid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- f
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-10-
|
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|
|
@@ -35,12 +35,14 @@ extra_rdoc_files:
|
|
|
35
35
|
files:
|
|
36
36
|
- LICENSE.txt
|
|
37
37
|
- README.md
|
|
38
|
+
- lib/jekyll/drops/url_drop_decorator.rb
|
|
38
39
|
- lib/jekyll/filters/assertion.rb
|
|
39
40
|
- lib/jekyll/filters/compact.rb
|
|
40
41
|
- lib/jekyll/filters/date_local.rb
|
|
41
42
|
- lib/jekyll/filters/file.rb
|
|
42
43
|
- lib/jekyll/filters/infinite.rb
|
|
43
44
|
- lib/jekyll/filters/json.rb
|
|
45
|
+
- lib/jekyll/filters/menu.rb
|
|
44
46
|
- lib/jekyll/filters/number.rb
|
|
45
47
|
- lib/jekyll/filters/pry.rb
|
|
46
48
|
- lib/jekyll/filters/sample.rb
|