lib/sculptor/extensions/resource_helpers.rb in sculptor-0.0.7 vs lib/sculptor/extensions/resource_helpers.rb in sculptor-0.0.8

- old
+ new

@@ -19,18 +19,17 @@ def resource_dir(resource) resource.url.split('/').last end - def resources_for(dir, ext: 'html', exclude_indexes: false, sort_by: nil, ignore: nil) + def resources_for(dir, ext: 'html', exclude_indexes: false, sort_by: nil, ignore: nil, allow_hidden: false) filtered = sitemap.resources .reject {|r| r.url == dir} # Exclude main directory index - .reject {|r| r.data.hidden} # reject hidden (Front matter) .select {|r| r.url.start_with?(dir)} # Select files in the given dir collect_resources(filtered, - { ext: ext, exclude_indexes: exclude_indexes, sort_by: sort_by, ignore: ignore} + { ext: ext, exclude_indexes: exclude_indexes, sort_by: sort_by, ignore: ignore, allow_hidden: allow_hidden} ) end def resource_tree(dir, ext: 'html', data_fields: [:title], exclude_indexes: false, sort_by: nil, ignore: nil) res = resources_for(dir, ext: ext, exclude_indexes: exclude_indexes, sort_by: sort_by, ignore: ignore) @@ -95,15 +94,18 @@ def collect_resources(resources, options) resources .select {|r| r.ext == ".#{options[:ext]}"} # Select files only HTML files .sort_by {|r| r.url } # Sort by url (default) .sort_by {|r| r.data[options[:sort_by]] || -1} # Sort by `sort_by` param + .reject {|r| # Reject hidden (Front matter) + r.data.hidden unless options[:allow_hidden] + } .reject {|r| # Exclude all directory indexes options[:exclude_indexes] ? r.directory_index? : false } .reject {|r| ignore ? r.url.match(options[:ignore]) : false } # Ignore URLs matching pattern (if provided) .reject {|r| r.path.end_with? ("-standalone#{r.ext}")} # Ignore proxied '-standalone' mode pages - .reject {|r| r.path.start_with? ("partials/")} # Ignore partials + .reject {|r| r.path.start_with? ("glyptotheque/")} # Ignore Sculptor’s partials end def parse_resource(r, options) data = {} data[:url] = r.url