Commit 57421293 authored by Chris Snijder's avatar Chris Snijder 🏅
Browse files

Fix bad use of safe navigation.

parent 0cc93d2b
......@@ -53,8 +53,8 @@ class RecursiveNav < ::Middleman::Extension
if meta = _meta_file(path)
@data = meta
end
@weight = meta&.nav&.weight || 99999
@title = meta&.nav&.title || meta&.title || File.basename(path).capitalize
@weight = meta.nav.weight rescue 99999
@title = meta.nav.title rescue meta.title rescue File.basename(path).capitalize
@path = path
@page_id = page_id
@url = nil
......@@ -106,7 +106,7 @@ class RecursiveNav < ::Middleman::Extension
@data = meta
end
@data.deep_merge!(resource.data)
@weight = @data&.nav&.weight || 99999
@weight = @data.nav.weight rescue 99999
@title = @data.title
@path = File.dirname(
resource.source_file.sub(/^#{__dir__}\/source\//, '')
......@@ -114,8 +114,16 @@ class RecursiveNav < ::Middleman::Extension
@page_id = resource.page_id
@url = resource.url
@locale = resource.options[:locale]
@nav = resource.data&.nav || Middleman::Util::EnhancedHash.new
@nav_title = @data&.nav&.title || @data&.title || resource.title
@nav = resource.data.nav rescue Middleman::Util::EnhancedHash.new
begin
@nav_title = @data.nav.title
rescue
@nav_title = @data&.title
rescue
@nav_title = resource.title
rescue
@nav_title = "No title set"
end
@resource = resource
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment