middleman-navigation 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -0
- data/lib/middleman-navigation/tree.rb +15 -8
- data/lib/middleman-navigation/version.rb +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -54,4 +54,8 @@ Example:
|
|
54
54
|
|
55
55
|
*title*: is used to set a custom title to menu, default to file name
|
56
56
|
|
57
|
+
### Root Item
|
57
58
|
|
59
|
+
The site root is now included by default in the navigation. If you'd like it to be hidden, you can set hidden to true in the frontmatter for the index page. Unlike other pages, the children of the hidden index page will still be visible!
|
60
|
+
|
61
|
+
Because it seems like the most reasonable semantic HTML, the site root is included at the same level as its children, at the beginning of the list. That doesn't support using weight to sort, but that could change if it becomes desirable.
|
@@ -3,12 +3,11 @@ module Middleman
|
|
3
3
|
class Tree
|
4
4
|
def self.build(sitemap)
|
5
5
|
@app = sitemap.app
|
6
|
-
|
7
|
-
root = sitemap.find_resource_by_destination_path root_path
|
6
|
+
@root = sitemap.find_resource_by_destination_path @app.http_prefix+@app.index_file
|
8
7
|
|
9
|
-
unless root.blank?
|
8
|
+
unless @root.blank?
|
10
9
|
SimpleNavigation::Configuration.run do |navigation|
|
11
|
-
traverse(root, navigation)
|
10
|
+
traverse(@root, navigation)
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
@@ -18,11 +17,12 @@ module Middleman
|
|
18
17
|
|
19
18
|
unless children.blank?
|
20
19
|
navigation.items do |level|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
if resource == @root
|
21
|
+
add_navigation_node @root, level unless @root.data.navigation[:hidden]
|
22
|
+
end
|
24
23
|
|
25
|
-
|
24
|
+
children.each do |child|
|
25
|
+
add_navigation_node child, level
|
26
26
|
traverse child, level
|
27
27
|
end
|
28
28
|
end
|
@@ -35,6 +35,13 @@ module Middleman
|
|
35
35
|
visible.sort! {|a, b| a.data.navigation[:weight] <=> b.data.navigation[:weight]}
|
36
36
|
visible
|
37
37
|
end
|
38
|
+
|
39
|
+
def self.add_navigation_node(node, level)
|
40
|
+
title = node.data.navigation[:title] || node.data.title
|
41
|
+
url = node.data.navigation[:destination] || node.url
|
42
|
+
|
43
|
+
level.item node.destination_path, title, url, :highlights_on => %r(#{url}(#{@app.index_file})?)
|
44
|
+
end
|
38
45
|
end
|
39
46
|
end
|
40
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: middleman
|