jekyll-menu 0.1.0 → 0.1.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 +4 -4
- data/lib/jekyll/menu.rb +28 -13
- data/lib/jekyll/menu/version.rb +1 -1
- data/restt_menu_post.rb +21 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7939c3f0181f1519aae1d25f8c5f5734add31a5f
|
4
|
+
data.tar.gz: 0d54f8923ebc3dcfe5aa810bbe432e162e639629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61591fcc459ac8dcb9720a8338f1c55cb73ee95cbbc14f611e5b9bf30397dfe871534a2333a68f3aeca2bc66068e28e70bb7d028f03e68365eadd05e0370b000
|
7
|
+
data.tar.gz: 279a9399638e43add90c109baa28100c4db728cc4730e8e8de6e5599523a60410b01eb100055e0be43ae479b6704670fc2af29b4ddff4b5046907eee0ba1cc6f
|
data/lib/jekyll/menu.rb
CHANGED
@@ -11,6 +11,8 @@ module Jekyll
|
|
11
11
|
"menu_active_class" => "is-active",
|
12
12
|
"item_class" => "c-menu__item",
|
13
13
|
"item_active_class" => "is-active",
|
14
|
+
"item_sub_class" => "has-sub-menu",
|
15
|
+
"link_class" => "c-menu__link",
|
14
16
|
}
|
15
17
|
|
16
18
|
def self.initialize(data)
|
@@ -26,7 +28,8 @@ module Jekyll
|
|
26
28
|
menus = @site.data["menus"].map { |m|
|
27
29
|
title = m[0]
|
28
30
|
items = m[1]
|
29
|
-
|
31
|
+
sub = false
|
32
|
+
m[1] = self.setup_menu(items, title, sub)
|
30
33
|
m
|
31
34
|
}
|
32
35
|
@data.data["menu"] = Hash[*menus.flatten(1)]
|
@@ -48,14 +51,15 @@ module Jekyll
|
|
48
51
|
def self.setup_menu_items(items, path)
|
49
52
|
path = path ? path : @options["url_path"]
|
50
53
|
items.map { |i|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
item["
|
54
|
+
item = {}
|
55
|
+
item["title"] = i["title"]
|
56
|
+
item["link"] = self.item_link(i, path)
|
57
|
+
item["class"] = self.item_class(item["link"], i.key?("items"))
|
58
|
+
item["link_class"] = self.link_class(item["link"])
|
59
|
+
item["active"] = self.item_is_active(item["link"])
|
60
|
+
if i.key?("items")
|
61
|
+
item["menu"] = self.setup_menu(i["items"], i["title"], true)
|
62
|
+
item["link"] = "#"
|
59
63
|
end
|
60
64
|
item
|
61
65
|
}
|
@@ -80,9 +84,9 @@ module Jekyll
|
|
80
84
|
class_name = @options["menu_class"]
|
81
85
|
if sub
|
82
86
|
class_name = "#{class_name} #{@options['menu_sub_class']}"
|
83
|
-
|
84
|
-
|
85
|
-
|
87
|
+
if self.menu_has_active_item(items)
|
88
|
+
class_name = "#{class_name} #{@options['menu_active_class']}"
|
89
|
+
end
|
86
90
|
end
|
87
91
|
class_name
|
88
92
|
end
|
@@ -127,11 +131,22 @@ module Jekyll
|
|
127
131
|
url === path
|
128
132
|
end
|
129
133
|
|
130
|
-
def self.item_class(path)
|
134
|
+
def self.item_class(path, has_items = false)
|
131
135
|
class_name = @options["item_class"]
|
132
136
|
if self.item_is_active(path)
|
133
137
|
class_name = "#{class_name} #{@options['item_active_class']}"
|
134
138
|
end
|
139
|
+
if has_items
|
140
|
+
class_name = "#{class_name} #{@options['item_sub_class']}"
|
141
|
+
end
|
142
|
+
class_name
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.link_class(path)
|
146
|
+
class_name = @options["link_class"]
|
147
|
+
if self.item_is_active(path)
|
148
|
+
class_name = "#{class_name} #{@options['item_active_class']}"
|
149
|
+
end
|
135
150
|
class_name
|
136
151
|
end
|
137
152
|
|
data/lib/jekyll/menu/version.rb
CHANGED
data/restt_menu_post.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTemplate < JekyllUnitTest
|
4
|
+
context "jekyll-menu" do
|
5
|
+
setup do
|
6
|
+
@site = Site.new(site_configuration)
|
7
|
+
@site.read
|
8
|
+
@site.generate
|
9
|
+
@site.render
|
10
|
+
end
|
11
|
+
|
12
|
+
should "post: active item class is added to current post" do
|
13
|
+
post = @site.posts[0]
|
14
|
+
menu = post["menu"]["test-post"]
|
15
|
+
item = menu[1]
|
16
|
+
|
17
|
+
assert_equal(true, item["active"])
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ItsJonQ
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/jekyll-menu.rb
|
157
157
|
- lib/jekyll/menu.rb
|
158
158
|
- lib/jekyll/menu/version.rb
|
159
|
+
- restt_menu_post.rb
|
159
160
|
homepage: https://github.com/helpscout/jekyll-menu
|
160
161
|
licenses:
|
161
162
|
- MIT
|