jekyll-awesome-nav 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 76b40b8ac598c39b7d6ea9b1235a4089893bd73e52d8722e8a2c4af8115aa468
4
- data.tar.gz: d4109676b6da69d8f40d623b55d40087d57c45f46c718fa349116a9080807bf9
3
+ metadata.gz: 8b77d4ad15599d518da1a7535f19fc68b945e6e16544b8198f591f94aab1bed5
4
+ data.tar.gz: f9c47d4e02a46679fa8e87f838ed9c2cb00d5b4d1bb0c5dfd7c4f561bc4b4366
5
5
  SHA512:
6
- metadata.gz: 89bb231311898453666edc086e0a54d6593d6c2644749e4f8a021253b0d272bb56f9bb0c522b9eac17314ea94ccd33e0d2289bd01dde5b69fc9f5f95b2b61ec9
7
- data.tar.gz: 7c05e014b8ad8ae8d6fc31f3382af750f10bde1d481f1ad1e19def058645c85e6a4db8b95514a674736da12170e2a49d30898a248ed8c4296d526f967257823c
6
+ metadata.gz: 925d4fc6bc37d7243c906f480f017b96ec48f7315a1e18a42ab8b08060445ffe868ee5f592945fc1ae446e08c0fb5a68ef1079d8237ad78354f65612675ba565
7
+ data.tar.gz: a01bbf7f22823601fb1c6bc34e2b2ace36a69618af1ba584c2c0d3aef62fdd4ffb76715db5663b9fa6e74246e3295b8c363869c4ac3331977c52c2339d506fcd
@@ -42,7 +42,7 @@ module Jekyll
42
42
 
43
43
  def breadcrumbs_for(page)
44
44
  page_url = Utils.normalize_url(page.url)
45
- trail = find_trail(serialized_tree, page_url)
45
+ trail = find_trail(internal_serialized_tree, page_url)
46
46
  return root_breadcrumb(page) if trail.nil? && Utils.source_dir_for(page) == @root_dir && Utils.index_page?(page)
47
47
  return [] unless trail
48
48
 
@@ -51,12 +51,10 @@ module Jekyll
51
51
 
52
52
  crumb = { "title" => item["title"] }
53
53
  crumb["url"] = item["url"] if item["url"]
54
+ crumb["dir"] = item["__dir"] if item.key?("__dir")
54
55
  crumb
55
56
  end
56
57
 
57
- breadcrumbs = trim_root_breadcrumb(breadcrumbs)
58
- return breadcrumbs if @root_dir.empty?
59
-
60
58
  prepend_root_breadcrumb(breadcrumbs)
61
59
  end
62
60
 
@@ -66,6 +64,10 @@ module Jekyll
66
64
 
67
65
  private
68
66
 
67
+ def internal_serialized_tree
68
+ @internal_serialized_tree ||= Serializer.serialize_tree(@tree, include_internal: true)
69
+ end
70
+
69
71
  def local_nav_nodes
70
72
  @local_nav_nodes ||= begin
71
73
  map = { @root_dir => @tree.map(&:deep_dup) }
@@ -87,15 +89,14 @@ module Jekyll
87
89
  end
88
90
 
89
91
  def root_breadcrumb(page)
90
- title = page.data["nav_title"] || page.data["title"] || Utils.titleize(Utils.last_segment(@root_dir))
91
- title = resolved_root_title if title.to_s.empty?
92
- [{ "title" => title, "url" => Utils.normalize_url(page.url) }]
92
+ [{ "title" => root_breadcrumb_title, "url" => Utils.normalize_url(page.url), "dir" => @root_dir }]
93
93
  end
94
94
 
95
95
  def prepend_root_breadcrumb(breadcrumbs)
96
96
  root_crumb = {
97
- "title" => resolved_root_title,
98
- "url" => Utils.normalize_url(@root_page&.url || "/#{@root_dir}/")
97
+ "title" => root_breadcrumb_title,
98
+ "url" => Utils.normalize_url(@root_page&.url || "/#{@root_dir}/"),
99
+ "dir" => @root_dir
99
100
  }
100
101
 
101
102
  return [root_crumb] + breadcrumbs[1..] if same_breadcrumb_url?(breadcrumbs.first, root_crumb)
@@ -103,25 +104,12 @@ module Jekyll
103
104
  [root_crumb] + breadcrumbs
104
105
  end
105
106
 
106
- def trim_root_breadcrumb(breadcrumbs)
107
- return breadcrumbs if breadcrumbs.empty?
108
-
109
- root_crumb = {
110
- "title" => resolved_root_title,
111
- "url" => Utils.normalize_url(@root_page&.url || "/#{@root_dir}/")
112
- }
113
-
114
- return breadcrumbs unless same_breadcrumb_url?(breadcrumbs.first, root_crumb)
115
-
116
- breadcrumbs[1..] || []
117
- end
118
-
119
107
  def neighbor_map
120
108
  @neighbor_map ||= begin
121
109
  items = []
122
110
  if @root_page
123
111
  items << {
124
- "title" => resolved_root_title,
112
+ "title" => root_breadcrumb_title,
125
113
  "url" => Utils.normalize_url(@root_page.url)
126
114
  }
127
115
  end
@@ -168,6 +156,12 @@ module Jekyll
168
156
  Utils.normalize_url(left["url"]) == Utils.normalize_url(right["url"])
169
157
  end
170
158
 
159
+ def root_breadcrumb_title
160
+ return "home" if @root_dir.empty?
161
+
162
+ resolved_root_title
163
+ end
164
+
171
165
  def resolved_root_title
172
166
  title = @root_page&.data&.fetch("nav_title", nil) ||
173
167
  @root_page&.data&.fetch("title", nil) ||
@@ -18,7 +18,7 @@ module Jekyll
18
18
  item = { "title" => node.title }
19
19
  item["url"] = node.url if node.url
20
20
  item["children"] = serialize_tree(node.children, include_internal: include_internal) if node.section? && node.children.any?
21
- item["__dir"] = node.dir if include_internal && node.dir
21
+ item["__dir"] = node.dir if include_internal && !node.dir.nil?
22
22
  item
23
23
  end
24
24
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Jekyll
4
4
  module AwesomeNav
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
 
7
7
  def self.warn_if_unstamped_version(output = $stderr)
8
8
  return unless VERSION == "0.0.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-awesome-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allison Thackston