find keys also in assigned collections

This commit is contained in:
Florian Thomas 2016-09-22 22:14:14 +03:00 committed by Parker Moore
parent dbea1ca80b
commit dde0441b3a
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
2 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,10 @@ module Jekyll
end
end
def key?(key)
(@obj.collections.key?(key) && key != "posts") || super
end
def posts
@site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
end

21
test/test_site_drop.rb Normal file
View File

@ -0,0 +1,21 @@
require "helper"
class TestSiteDrop < JekyllUnitTest
context "a site drop" do
setup do
@site = fixture_site({
"collections" => ["thanksgiving"]
})
@site.process
@drop = @site.to_liquid.site
end
should "respond to `key?`" do
assert @drop.respond_to?(:key?)
end
should "find a key if it's in the collection of the drop" do
assert @drop.key?("thanksgiving")
end
end
end