Only write collections.posts.permalink if permalink is set.

This commit is contained in:
Parker Moore 2016-04-04 11:49:24 -07:00 committed by Pat Hawks
parent c69ca4c11e
commit f2263a11b7
1 changed files with 8 additions and 2 deletions

View File

@ -72,7 +72,7 @@ module Jekyll
'hard_wrap' => false, 'hard_wrap' => false,
'footnote_nr' => 1 'footnote_nr' => 1
} }
}] }].freeze
# Public: Turn all keys into string # Public: Turn all keys into string
# #
@ -271,14 +271,20 @@ module Jekyll
def add_default_collections def add_default_collections
config = clone config = clone
# It defaults to `{}`, so this is only if someone sets it to null manually.
return config if config['collections'].nil? return config if config['collections'].nil?
# Ensure we have a hash.
if config['collections'].is_a?(Array) if config['collections'].is_a?(Array)
config['collections'] = Hash[config['collections'].map { |c| [c, {}] }] config['collections'] = Hash[config['collections'].map { |c| [c, {}] }]
end end
# Add posts.
config['collections']['posts'] ||= {} config['collections']['posts'] ||= {}
config['collections']['posts']['output'] = true config['collections']['posts']['output'] = true
config['collections']['posts']['permalink'] = style_to_permalink(config['permalink']) if config['permalink']
config['collections']['posts']['permalink'] ||= style_to_permalink(config['permalink'])
end
config config
end end