lib/cloudcannon-jekyll/generators/collections.rb in cloudcannon-jekyll-4.0.0 vs lib/cloudcannon-jekyll/generators/collections.rb in cloudcannon-jekyll-4.0.1
- old
+ new
@@ -20,10 +20,20 @@
@data_dir = Paths.data_dir(site)
@split_posts = group_by_category_folder(all_posts, 'posts')
@split_drafts = group_by_category_folder(all_drafts, 'drafts')
end
+ def generate_collections_config_path(key)
+ if key.end_with?("/posts")
+ File.join(@collections_dir, key.sub(/\/posts$/, "/_posts"))
+ elsif key.end_with?("/drafts")
+ File.join(@collections_dir, key.sub(/\/drafts$/, "/_drafts"))
+ else
+ File.join(@collections_dir, "_#{key}")
+ end
+ end
+
def generate_collections_config
collections = @site.config['collections'] || {}
collections_config = @config['collections_config'] || {}
return collections_config if @config['collections_config_override']
@@ -60,10 +70,10 @@
.merge(collections[key] || {})
.merge(collections_config[key] || {})
processed['output'] ||= false
processed['auto_discovered'] = !collections_config.key?(key)
- processed['path'] ||= File.join(@collections_dir, "_#{key}")
+ processed['path'] ||= generate_collections_config_path(key)
processed['path'] = processed['path'].sub(%r{^/+}, '')
Config.rename_legacy_collection_config_keys(processed)
collections_config[key] = processed