diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index c8da0e52..e15cf7c6 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -361,7 +361,9 @@ module Jekyll private def item_property(item, property) if item.respond_to?(:to_liquid) - item.to_liquid[property.to_s] + property.to_s.split(".").reduce(item.to_liquid) do |subvalue, attribute| + subvalue[attribute] + end elsif item.respond_to?(:data) item.data[property.to_s] else diff --git a/test/test_filters.rb b/test/test_filters.rb index 243f97af..93ddb2cd 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -949,6 +949,12 @@ class TestFilters < JekyllUnitTest assert_equal [{ "a" => 1 }, { "a" => 2 }, { "b" => 1 }], @filter.sort([{ "a" => 2 }, { "b" => 1 }, { "a" => 1 }], "a", "last") end + should "return sorted by subproperty array" do + assert_equal [{ "a" => { "b" => 1 } }, { "a" => { "b" => 2 } }, + { "a" => { "b" => 3 } }, ], + @filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } }, + { "a" => { "b" => 3 } }, ], "a.b") + end end context "to_integer filter" do