class Middleman::CoreExtensions::Routing
def before_configuration
def before_configuration app.add_to_config_context(:page, &method(:page)) end
def initialize(app, options_hash={}, &block)
def initialize(app, options_hash={}, &block) super @page_configs = Set.new end
def manipulate_resource_list(resources)
def manipulate_resource_list(resources) resources.each do |resource| @page_configs.each do |p| resource.add_metadata(p[:metadata]) if Middleman::Util.path_match(p[:path], "/#{resource.path}") end end end
def page(path, opts={})
def page(path, opts={}) options = opts.dup # Default layout metadata = { options: options, locals: options.delete(:locals) || {}, page: options.delete(:data) || {} } if path.is_a?(String) && !path.include?('*') # Normalize path path = Middleman::Util.normalize_path(path) if path.end_with?('/') || app.files.by_type(:source).watchers.any? { |w| (w.directory + Pathname(path)).directory? } path = File.join(path, @app.config[:index_file]) end end path = '/' + Util.strip_leading_slash(path) if path.is_a?(String) @page_configs << PageDescriptor.new(path, metadata) end