Minor performance fix to not double-compute metadata in directory_indexes.

This commit is contained in:
Ben Hollis 2013-04-06 12:15:05 -07:00
parent 044b49d83b
commit 14a39e5e87
2 changed files with 6 additions and 9 deletions

View file

@ -36,15 +36,15 @@ Feature: link_to helper
And a file named "source/link_to.html.erb" with:
"""
<% menu_items.each do |item| %>
<%= link_to(item.metadata[:page]['title'], item.url) %>
<%= link_to(item.metadata[:page]['title'], item) %>
<%= link_to(item.data['title'], item.url) %>
<%= link_to(item.data['title'], item) %>
<% end %>
"""
And a file named "source/link_to/sub.html.erb" with:
"""
<% menu_items.each do |item| %>
<%= link_to(item.metadata[:page]['title'], item.url) %>
<%= link_to(item.metadata[:page]['title'], item) %>
<%= link_to(item.data['title'], item.url) %>
<%= link_to(item.data['title'], item) %>
<% end %>
"""
And the Server is running at "indexable-app"

View file

@ -40,13 +40,10 @@ module Middleman
File.extname(index_file) != resource.ext
# Check if frontmatter turns directory_index off
d = resource.raw_data
next if d && d[:directory_index] == false
next if resource.data[:directory_index] == false
# Check if file metadata (options set by "page" in config.rb) turns directory_index off
if resource.metadata[:options] && resource.metadata[:options][:directory_index] == false
next
end
next if resource.metadata[:options][:directory_index] == false
resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path
end