Fixes #1821
This commit is contained in:
parent
c44f7482b1
commit
7b59f240d5
2 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,10 @@
|
|||
master
|
||||
===
|
||||
|
||||
* Fix directory indexes with `.htm` files. #1821
|
||||
|
||||
# 4.1.2
|
||||
|
||||
* Add `page_id` concept. Using the `id` key in frontmatter, proxy or page will set an ID on a resource which can be referenced by `url_for` and `link_to`.
|
||||
* Allow looking for `Gemfile` when setting up a project to fail gracefully.
|
||||
* Send correct exit code when external_pipeline fails during build.
|
||||
|
|
|
@ -11,16 +11,22 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
|
|||
index_file = app.config[:index_file]
|
||||
new_index_path = "/#{index_file}"
|
||||
|
||||
extensions = %w(.htm .html .php)
|
||||
|
||||
resources.each do |resource|
|
||||
# Check if it would be pointless to reroute
|
||||
next if resource.destination_path == index_file ||
|
||||
resource.destination_path.end_with?(new_index_path) ||
|
||||
File.extname(index_file) != resource.ext
|
||||
!extensions.include?(resource.ext)
|
||||
|
||||
# Check if file metadata (options set by "page" in config.rb or frontmatter) turns directory_index off
|
||||
next if resource.options[:directory_index] == false
|
||||
|
||||
resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path
|
||||
extensions.each do |ext|
|
||||
resource.destination_path = resource.destination_path.chomp(ext)
|
||||
end
|
||||
|
||||
resource.destination_path += new_index_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue