Sha256: 7cd356ca6c3570f349537dee49774b23f628a840ea8cfbae2b8f65874ae67294

Contents?: true

Size: 1.1 KB

Versions: 40

Compression:

Stored size: 1.1 KB

Contents

ignore '*.frontmatter'

# Reads neighbor for every file on every refresh.
# TODO: Optimize
class NeighborFrontmatter < ::Middleman::Extension
  self.resource_list_manipulator_priority = 81

  def manipulate_resource_list(resources)
    resources.each do |resource|
      next unless resource.file_descriptor

      neighbor = "#{resource.file_descriptor[:relative_path]}.frontmatter"

      file = app.files.find(:source, neighbor)

      next unless file

      fmdata = ::Middleman::Util::Data.parse(file, app.config[:frontmatter_delims], :yaml).first
      opts = fmdata.extract!(:layout, :layout_engine, :renderer_options, :directory_index, :content_type)
      opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
      ignored = fmdata.delete(:ignored)
      resource.add_metadata options: opts, page: fmdata
      resource.ignore! if ignored == true && !resource.is_a?(::Middleman::Sitemap::ProxyResource)
    end
  end
end

Middleman::Extensions.register :neighbor_frontmatter, NeighborFrontmatter unless Middleman::Extensions.registered.include? :neighbor_frontmatter

activate :neighbor_frontmatter

Version data entries

40 entries across 40 versions & 3 rubygems

Version Path
middleman-core-4.6.0 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.5.1 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.5.0 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.4.3 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.4.2 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.4.0 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.11 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.10 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.8 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.7 fixtures/frontmatter-neighbor-app/config.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-core-4.3.3/fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.6 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.5 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.4 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.3 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.2 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.1 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.0 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.0.rc.4 fixtures/frontmatter-neighbor-app/config.rb
middleman-core-4.3.0.rc.3 fixtures/frontmatter-neighbor-app/config.rb