Method: MiddlemanMdocs::Navigation#fuzzy_find_resource

Defined in:
lib/middleman-mdocs/navigation.rb

#fuzzy_find_resource(url) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/middleman-mdocs/navigation.rb', line 83

def fuzzy_find_resource(url)
  source_file = if url.try(:source_file)
                  url.try(:source_file)
                elsif url.start_with?('/')
                  app.source_dir.join(url[1..-1]).to_s
                elsif current_page
                  Pathname.new(current_page.source_file).dirname.join(url).to_s
                else
                  url
                end
  app.sitemap.resources.find { |r| r.source_file == source_file }
end