NO MORE DATA COLLECTION I CAN'T HANDLE IT
This commit is contained in:
parent
764dc88832
commit
fb39b41ffb
|
@ -195,17 +195,18 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing
|
||||
def read_data(dir)
|
||||
unless dir.to_s.eql?("_data")
|
||||
Jekyll.logger.error "Error:", "Data source directories other than '_data' have been removed.\n" +
|
||||
"Please move your YAML files to `_data` and remove the `data_source` key from your `_config.yml`."
|
||||
end
|
||||
base = File.join(source, dir)
|
||||
return unless File.directory?(base) && (!safe || !File.symlink?(base))
|
||||
|
||||
collections['data'] = Jekyll::Collection.new(self, "data")
|
||||
collections['data'].read
|
||||
entries = Dir.chdir(base) { Dir['*.{yaml,yml}'] }
|
||||
entries.delete_if { |e| File.directory?(File.join(base, e)) }
|
||||
|
||||
collections['data'].docs.each do |doc|
|
||||
key = sanitize_filename(doc.basename(".*"))
|
||||
self.data[key] = doc.data
|
||||
entries.each do |entry|
|
||||
path = File.join(source, dir, entry)
|
||||
next if File.symlink?(path) && safe
|
||||
|
||||
key = sanitize_filename(File.basename(entry, '.*'))
|
||||
self.data[key] = SafeYAML.load_file(path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -57,10 +57,8 @@ class TestCollections < Test::Unit::TestCase
|
|||
@site.process
|
||||
end
|
||||
|
||||
should "not contain any collections other than the default ones" do
|
||||
collections = @site.collections.dup
|
||||
assert collections.delete("data").is_a?(Jekyll::Collection)
|
||||
assert_equal Hash.new, collections
|
||||
should "not contain any collections" do
|
||||
assert_equal Hash.new, @site.collections
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue