jekyll-awesome-nav 0.1.2 → 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: 2cfc859de2a4762ba5046338aa7bc12049da70bfb2d9ac27d727eace95322f11
4
- data.tar.gz: 0f14a593b81ec5882b65db61b82e93d8bd8f9a3656a8d730cd0f4175a2da65e3
3
+ metadata.gz: 8b77d4ad15599d518da1a7535f19fc68b945e6e16544b8198f591f94aab1bed5
4
+ data.tar.gz: f9c47d4e02a46679fa8e87f838ed9c2cb00d5b4d1bb0c5dfd7c4f561bc4b4366
5
5
  SHA512:
6
- metadata.gz: 39eccdb01ce4ecd9c828f2c66b6997b6ef769ec199ffb6a94a206fa6f449c615f84edf7928290029adde02b97bdc24a9050ae70654047915181c26bd81c72a49
7
- data.tar.gz: '008767e37db8c06b2b2c77ffa4a1cc9f437653a33684a90994d7e7da854b836b5c39687ed3065d0adcd1e6692f757a1e9346cec259e85725d5853495112f33bb'
6
+ metadata.gz: 925d4fc6bc37d7243c906f480f017b96ec48f7315a1e18a42ab8b08060445ffe868ee5f592945fc1ae446e08c0fb5a68ef1079d8237ad78354f65612675ba565
7
+ data.tar.gz: a01bbf7f22823601fb1c6bc34e2b2ace36a69618af1ba584c2c0d3aef62fdd4ffb76715db5663b9fa6e74246e3295b8c363869c4ac3331977c52c2339d506fcd
@@ -1,5 +1,5 @@
1
1
  # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2
- _commit: afa589e
2
+ _commit: 618054b
3
3
  _src_path: gh:athackst/ci
4
4
  automerge_mode: poll
5
5
  bump_script_path: ''
data/.vscode/tasks.json CHANGED
@@ -65,6 +65,59 @@
65
65
  "endsPattern": ".*Server address:.*"
66
66
  }
67
67
  }
68
+ },
69
+ {
70
+ "label": "Build Fixture Preview",
71
+ "type": "shell",
72
+ "command": "bundle exec jekyll build --source test/fixtures/${input:fixtureName} --config test/fixtures/${input:fixtureName}/_config.yml,test/fixtures/_preview_theme/_config.preview.yml --destination _site/fixtures/${input:fixtureName}",
73
+ "options": {
74
+ "cwd": "${workspaceFolder}"
75
+ },
76
+ "group": "build",
77
+ "problemMatcher": []
78
+ },
79
+ {
80
+ "label": "Serve Fixture Preview",
81
+ "type": "shell",
82
+ "command": "bundle exec jekyll serve --source test/fixtures/${input:fixtureName} --config test/fixtures/${input:fixtureName}/_config.yml,test/fixtures/_preview_theme/_config.preview.yml --destination _site/fixtures/${input:fixtureName} --livereload --port 4011",
83
+ "options": {
84
+ "cwd": "${workspaceFolder}"
85
+ },
86
+ "isBackground": true,
87
+ "problemMatcher": {
88
+ "owner": "jekyll",
89
+ "pattern": {
90
+ "regexp": ".",
91
+ "file": 1,
92
+ "location": 1,
93
+ "message": 1
94
+ },
95
+ "background": {
96
+ "activeOnStart": true,
97
+ "beginsPattern": ".*Generating.*",
98
+ "endsPattern": ".*Server address:.*"
99
+ }
100
+ }
101
+ }
102
+ ],
103
+ "inputs": [
104
+ {
105
+ "id": "fixtureName",
106
+ "type": "pickString",
107
+ "description": "Choose which Jekyll fixture to preview",
108
+ "default": "site",
109
+ "options": [
110
+ "external_override",
111
+ "invalid_override",
112
+ "manual_dedup",
113
+ "nav_features",
114
+ "nested_manual_dedup",
115
+ "readme_index",
116
+ "readme_manual_section",
117
+ "root_site",
118
+ "site",
119
+ "untitled_index"
120
+ ]
68
121
  }
69
122
  ]
70
123
  }
@@ -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,6 +51,7 @@ 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
 
@@ -63,6 +64,10 @@ module Jekyll
63
64
 
64
65
  private
65
66
 
67
+ def internal_serialized_tree
68
+ @internal_serialized_tree ||= Serializer.serialize_tree(@tree, include_internal: true)
69
+ end
70
+
66
71
  def local_nav_nodes
67
72
  @local_nav_nodes ||= begin
68
73
  map = { @root_dir => @tree.map(&:deep_dup) }
@@ -84,18 +89,17 @@ module Jekyll
84
89
  end
85
90
 
86
91
  def root_breadcrumb(page)
87
- title = page.data["nav_title"] || page.data["title"] || Utils.titleize(Utils.last_segment(@root_dir))
88
- title = resolved_root_title if title.to_s.empty?
89
- [{ "title" => title, "url" => Utils.normalize_url(page.url) }]
92
+ [{ "title" => root_breadcrumb_title, "url" => Utils.normalize_url(page.url), "dir" => @root_dir }]
90
93
  end
91
94
 
92
95
  def prepend_root_breadcrumb(breadcrumbs)
93
96
  root_crumb = {
94
- "title" => resolved_root_title,
95
- "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
96
100
  }
97
101
 
98
- return breadcrumbs if breadcrumbs.first == root_crumb
102
+ return [root_crumb] + breadcrumbs[1..] if same_breadcrumb_url?(breadcrumbs.first, root_crumb)
99
103
 
100
104
  [root_crumb] + breadcrumbs
101
105
  end
@@ -105,7 +109,7 @@ module Jekyll
105
109
  items = []
106
110
  if @root_page
107
111
  items << {
108
- "title" => resolved_root_title,
112
+ "title" => root_breadcrumb_title,
109
113
  "url" => Utils.normalize_url(@root_page.url)
110
114
  }
111
115
  end
@@ -146,6 +150,18 @@ module Jekyll
146
150
  Marshal.load(Marshal.dump(value))
147
151
  end
148
152
 
153
+ def same_breadcrumb_url?(left, right)
154
+ return false unless left && right
155
+
156
+ Utils.normalize_url(left["url"]) == Utils.normalize_url(right["url"])
157
+ end
158
+
159
+ def root_breadcrumb_title
160
+ return "home" if @root_dir.empty?
161
+
162
+ resolved_root_title
163
+ end
164
+
149
165
  def resolved_root_title
150
166
  title = @root_page&.data&.fetch("nav_title", nil) ||
151
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
@@ -63,8 +63,7 @@ module Jekyll
63
63
  end
64
64
  end
65
65
 
66
- def section_title_for_index(page, basename, current, resolved_title)
67
- return resolved_title unless basename.downcase == "readme"
66
+ def section_title_for_index(page, _basename, current, resolved_title)
68
67
  return resolved_title if page.data["nav_title"] || page.data["title"]
69
68
  return current.title unless current.title.to_s.empty?
70
69
 
@@ -90,8 +90,17 @@ module Jekyll
90
90
  normalize_dir(path)
91
91
  end
92
92
 
93
- def page_title(page, basename)
94
- page.data["nav_title"] || page.data["title"] || titleize(basename)
93
+ def page_title(page, basename = nil)
94
+ explicit_title = page.data["nav_title"] || page.data["title"]
95
+ return explicit_title if explicit_title
96
+
97
+ if index_page?(page)
98
+ directory_title = titleize(last_segment(source_dir_for(page)))
99
+ return directory_title unless directory_title.empty?
100
+ end
101
+
102
+ basename ||= File.basename(source_path_for(page), File.extname(source_path_for(page)))
103
+ titleize(basename)
95
104
  end
96
105
  end
97
106
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Jekyll
4
4
  module AwesomeNav
5
- VERSION = "0.1.2"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-awesome-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allison Thackston
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-13 00:00:00.000000000 Z
11
+ date: 2026-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll