2013-04-13 01:14:16 +02:00
|
|
|
# Proxy ignored.html, which should ignore itself through a frontmatter
|
2014-06-17 06:44:14 +02:00
|
|
|
proxy 'proxied.html', 'ignored.html'
|
2015-02-24 20:06:28 +01:00
|
|
|
proxy 'proxied_with_frontmatter.html', 'ignored.html'
|
2014-05-27 02:58:35 +02:00
|
|
|
page 'override_layout.html', layout: :alternate
|
2013-04-13 01:14:16 +02:00
|
|
|
page 'page_mentioned.html'
|
2014-07-04 04:44:26 +02:00
|
|
|
|
|
|
|
ignore '*.frontmatter'
|
|
|
|
|
|
|
|
# Reads neighbor for every file on every refresh.
|
|
|
|
class NeighborFrontmatter < ::Middleman::Extension
|
|
|
|
self.resource_list_manipulator_priority = 81
|
|
|
|
|
|
|
|
def manipulate_resource_list(resources)
|
|
|
|
resources.each do |resource|
|
2015-09-09 20:55:56 +02:00
|
|
|
next unless resource.file_descriptor
|
|
|
|
next if resource.file_descriptor[:relative_path].extname == '.frontmatter'
|
2015-02-24 20:06:28 +01:00
|
|
|
|
|
|
|
[
|
|
|
|
"#{resource.url.sub(/^\//, '')}.frontmatter",
|
2015-09-09 20:55:56 +02:00
|
|
|
"#{resource.file_descriptor[:relative_path]}.frontmatter"
|
2015-02-24 20:06:28 +01:00
|
|
|
].each do |n|
|
|
|
|
file = app.files.find(:source, n)
|
|
|
|
apply_neighbor_data(resource, file) if file
|
|
|
|
end
|
2014-07-04 04:44:26 +02:00
|
|
|
end
|
|
|
|
end
|
2015-02-24 20:06:28 +01:00
|
|
|
|
|
|
|
def apply_neighbor_data(resource, file)
|
2016-01-20 20:50:25 +01:00
|
|
|
fmdata = ::Middleman::Util::Data.parse(file, app.config[:frontmatter_delims], :yaml).first
|
2015-02-24 20:06:28 +01:00
|
|
|
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
|
2014-07-04 04:44:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
Middleman::Extensions.register :neighbor_frontmatter, NeighborFrontmatter unless Middleman::Extensions.registered.include? :neighbor_frontmatter
|
|
|
|
|
|
|
|
activate :neighbor_frontmatter
|