diff --git a/features/frontmatter_defaults.feature b/features/frontmatter_defaults.feature index c3e7c8de..41a7a35e 100644 --- a/features/frontmatter_defaults.feature +++ b/features/frontmatter_defaults.feature @@ -128,3 +128,9 @@ Feature: frontmatter defaults When I run jekyll build Then the _site directory should exist And I should see "Value: Override" in "_site/slides/slide2.html" + + Scenario: Deep merge frontmatter defaults + Given I have an "index.html" page with fruit "{orange: 1}" that contains "Fruits: {{ page.fruit.orange | plus: page.fruit.apple }}" + And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {fruit: {apple: 2}}}]" + When I run jekyll build + Then I should see "Fruits: 3" in "_site/index.html" diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 2c5755b5..42b85ed5 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -41,10 +41,10 @@ module Jekyll old_scope = nil matching_sets(path, type).each do |set| if has_precedence?(old_scope, set['scope']) - defaults.merge! set['values'] + defaults = Utils.deep_merge_hashes(defaults, set['values']) old_scope = set['scope'] else - defaults = set['values'].merge(defaults) + defaults = Utils.deep_merge_hashes(set['values'], defaults) end end defaults @@ -145,4 +145,4 @@ module Jekyll end end end -end \ No newline at end of file +end