lib/cloudcannon-jekyll/generators/collections.rb in cloudcannon-jekyll-4.0.4 vs lib/cloudcannon-jekyll/generators/collections.rb in cloudcannon-jekyll-4.0.5
- old
+ new
@@ -147,10 +147,18 @@
Logger.warn "⚠️ Ignoring #{doc.relative_path.bold} in #{key.bold} collection"
next
end
collections[key] ||= []
- collections[key].push(document_to_json(doc, key))
+
+ begin
+ jsonified = document_to_json(doc, key)
+ JSON.generate(jsonified) # this is here to catch JSON errors per file
+ collections[key].push(jsonified)
+ rescue
+ Logger.warn "⚠️ Failed to parse #{doc.relative_path.bold}"
+ end
+
assigned_pages[doc.relative_path] = true if doc.instance_of?(Jekyll::Page)
end
collections_config.each_key do |key|