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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0713a8fb9ae531c61b7f2b8503392bb2f7cafc96
4
- data.tar.gz: 2aa3309250b19e9bdf0718d35826b2abe363850a
3
+ metadata.gz: 7939c3f0181f1519aae1d25f8c5f5734add31a5f
4
+ data.tar.gz: 0d54f8923ebc3dcfe5aa810bbe432e162e639629
5
5
  SHA512:
6
- metadata.gz: 70b6051bee175d3665439b9c20fc3f8847a750ae59d54454f1f9026ec2381eeb503f716fc1e12c9c2d453946bb363c831030265b366ccc217187344d699f18a5
7
- data.tar.gz: a7297faf80d053dd4375104649865c091e983d50f9cc76c320aca2903e5857b9e21b9de94f1b2c9d597bdd7043402246142e695a2f1396f1041f098fe3cd5e87
6
+ metadata.gz: 61591fcc459ac8dcb9720a8338f1c55cb73ee95cbbc14f611e5b9bf30397dfe871534a2333a68f3aeca2bc66068e28e70bb7d028f03e68365eadd05e0370b000
7
+ data.tar.gz: 279a9399638e43add90c109baa28100c4db728cc4730e8e8de6e5599523a60410b01eb100055e0be43ae479b6704670fc2af29b4ddff4b5046907eee0ba1cc6f
@@ -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
- m[1] = self.setup_menu(items, title)["items"]
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
- if i.key?("pages")
52
- item = self.setup_menu(i["pages"], i["title"], true)
53
- else
54
- item = {}
55
- item["title"] = i["title"]
56
- item["link"] = self.item_link(i, path)
57
- item["class"] = self.item_class(item["link"])
58
- item["active"] = self.item_is_active(item["link"])
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
- end
84
- if self.menu_has_active_item(items)
85
- class_name = "#{class_name} #{@options['menu_active_class']}"
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
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Menu
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -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.0
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