Class: Middleman::Extensions::DirectoryIndexes
- Inherits:
-
Middleman::Extension
- Object
- Middleman::Extension
- Middleman::Extensions::DirectoryIndexes
- Defined in:
- lib/middleman-core/extensions/directory_indexes.rb
Overview
Directory Indexes extension
Constant Summary
Constants included from Contracts
Instance Attribute Summary
Attributes inherited from Middleman::Extension
Instance Method Summary collapse
Methods inherited from Middleman::Extension
activated_extension, #add_exposed_to_context, #after_build, #after_configuration, #after_extension_activated, after_extension_activated, #before_build, #before_configuration, clear_after_extension_callbacks, config, define_setting, expose_to_application, expose_to_config, expose_to_template, global_config, helpers, #initialize, option, #ready, resources
Methods included from Contracts
Constructor Details
This class inherits a constructor from Middleman::Extension
Instance Method Details
#manipulate_resource_list(resources) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/middleman-core/extensions/directory_indexes.rb', line 10 def manipulate_resource_list(resources) index_file = app.config[:index_file] new_index_path = "/#{index_file}" extensions = %w(.htm .html .php .xhtml) 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) || !extensions.include?(resource.ext) # Check if file metadata (options set by "page" in config.rb or frontmatter) turns directory_index off next if resource.[:directory_index] == false extensions.each do |ext| resource.destination_path = resource.destination_path.chomp(ext) end resource.destination_path += new_index_path end end |