diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 0fb6719f..248e6d15 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -206,7 +206,8 @@ module Jekyll "content" => content, "path" => path, "relative_path" => relative_path, - "url" => url + "url" => url, + "collection" => collection.label } else data diff --git a/site/docs/collections.md b/site/docs/collections.md index 47ecc462..91460c96 100644 --- a/site/docs/collections.md +++ b/site/docs/collections.md @@ -244,6 +244,16 @@ In addition to any YAML front-matter provided in the document's corresponding fi

+ + +

collection

+ + +

+ The name of the document's collection. +

+ + diff --git a/test/test_document.rb b/test/test_document.rb index 794c2117..672f7d2e 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -40,6 +40,10 @@ class TestDocument < Test::Unit::TestCase }, @document.data) end + should "output the collection name in the #to_liquid method" do + assert_equal @document.to_liquid['collection'], "methods" + end + end context " a document part of a rendered collection" do