mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Merge pull request #2295 from jekyll/add-documents-listing
This commit is contained in:
@@ -228,5 +228,14 @@ module Jekyll
|
||||
path <=> anotherDocument.path
|
||||
end
|
||||
|
||||
# Determine whether this document should be written.
|
||||
# Based on the Collection to which it belongs.
|
||||
#
|
||||
# True if the document has a collection and if that collection's #write?
|
||||
# method returns true, otherwise false.
|
||||
def write?
|
||||
collection && collection.write?
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -325,6 +325,7 @@ module Jekyll
|
||||
"categories" => post_attr_hash('categories'),
|
||||
"tags" => post_attr_hash('tags'),
|
||||
"collections" => collections,
|
||||
"documents" => documents,
|
||||
"data" => site_data
|
||||
}))
|
||||
}
|
||||
@@ -405,18 +406,18 @@ module Jekyll
|
||||
end
|
||||
end
|
||||
|
||||
def docs_to_write
|
||||
documents.select(&:write?)
|
||||
end
|
||||
|
||||
def documents
|
||||
collections.reduce(Set.new) do |docs, (_, collection)|
|
||||
if collection.write?
|
||||
docs.merge(collection.docs)
|
||||
else
|
||||
docs
|
||||
end
|
||||
end
|
||||
docs.merge(collection.docs)
|
||||
end.to_a
|
||||
end
|
||||
|
||||
def each_site_file
|
||||
%w(posts pages static_files documents).each do |type|
|
||||
%w(posts pages static_files docs_to_write).each do |type|
|
||||
send(type).each do |item|
|
||||
yield item
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user