Sha256: 7bdd769f3e7a237ea1e3ccfc5d0ada7189140dd25913b539a137095d2f7a77a1

Contents?: true

Size: 946 Bytes

Versions: 31

Compression:

Stored size: 946 Bytes

Contents

# Directory Indexes extension
class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
  # Update the main sitemap resource list
  # @return [void]
  def manipulate_resource_list(resources)
    index_file = app.index_file
    new_index_path = "/#{index_file}"

    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

      # Check if frontmatter turns directory_index off
      next if resource.raw_data[:directory_index] == false

      # Check if file metadata (options set by "page" in config.rb) turns directory_index off
      next if resource.metadata[:options][:directory_index] == false

      resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
middleman-core-3.4.1 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.4.0 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.12 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.11 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.10 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.9 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.8 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.7 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.6 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.5 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-cj-3.3.6 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-cj-3.3.5 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-cj-3.3.4 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.4 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.3 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.2 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.1 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.3.0 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.2.2 lib/middleman-more/extensions/directory_indexes.rb
middleman-core-3.2.1 lib/middleman-more/extensions/directory_indexes.rb