Always render collections, just don't always write them
This commit is contained in:
parent
3a6ad0737c
commit
0dc680df0b
|
@ -112,7 +112,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the permalink or nil if no permalink was set in the data.
|
# Returns the permalink or nil if no permalink was set in the data.
|
||||||
def permalink
|
def permalink
|
||||||
data && data['permalink']
|
data && data.is_a?(Hash) && data['permalink']
|
||||||
end
|
end
|
||||||
|
|
||||||
# The computed URL for the document. See `Jekyll::URL#to_s` for more details.
|
# The computed URL for the document. See `Jekyll::URL#to_s` for more details.
|
||||||
|
@ -192,12 +192,16 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns a Hash representing this Document's data.
|
# Returns a Hash representing this Document's data.
|
||||||
def to_liquid
|
def to_liquid
|
||||||
|
if data.is_a?(Hash)
|
||||||
Utils.deep_merge_hashes data, {
|
Utils.deep_merge_hashes data, {
|
||||||
"content" => content,
|
"content" => content,
|
||||||
"path" => path,
|
"path" => path,
|
||||||
"relative_path" => relative_path,
|
"relative_path" => relative_path,
|
||||||
"url" => url
|
"url" => url
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
data
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The inspect string for this document.
|
# The inspect string for this document.
|
||||||
|
|
|
@ -111,13 +111,6 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The list of collections to render.
|
|
||||||
#
|
|
||||||
# The array of collection labels to render.
|
|
||||||
def to_render
|
|
||||||
@to_render ||= (config['render'] || Array.new)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Read Site data from disk and load it into internal data structures.
|
# Read Site data from disk and load it into internal data structures.
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
|
@ -240,8 +233,8 @@ module Jekyll
|
||||||
def render
|
def render
|
||||||
relative_permalinks_deprecation_method
|
relative_permalinks_deprecation_method
|
||||||
|
|
||||||
to_render.each do |label|
|
collections.each do |label, collection|
|
||||||
collections[label].docs.each do |document|
|
collection.docs.each do |document|
|
||||||
document.output = Jekyll::Renderer.new(self, document).run
|
document.output = Jekyll::Renderer.new(self, document).run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -411,9 +404,9 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def documents
|
def documents
|
||||||
collections.reduce(Set.new) do |docs, (label, coll)|
|
collections.reduce(Set.new) do |docs, (_, collection)|
|
||||||
if to_render.include?(label)
|
if collection.write?
|
||||||
docs.merge(coll.docs)
|
docs.merge(collection.docs)
|
||||||
else
|
else
|
||||||
docs
|
docs
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,6 +107,25 @@ class TestCollections < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a collection with metadata" do
|
||||||
|
setup do
|
||||||
|
@site = fixture_site({
|
||||||
|
"collections" => {
|
||||||
|
"methods" => {
|
||||||
|
"foo" => "bar",
|
||||||
|
"baz" => "whoo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
@site.process
|
||||||
|
@collection = @site.collections["methods"]
|
||||||
|
end
|
||||||
|
|
||||||
|
should "extract the configuration collection information as metadata" do
|
||||||
|
assert_equal @collection.metadata, {"foo" => "bar", "baz" => "whoo"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "in safe mode" do
|
context "in safe mode" do
|
||||||
setup do
|
setup do
|
||||||
@site = fixture_site({
|
@site = fixture_site({
|
||||||
|
|
Loading…
Reference in New Issue