Fix loading data from subdir with a period in name #5429
This commit is contained in:
parent
aa901cdaba
commit
cff8f2994c
|
@ -37,10 +37,10 @@ module Jekyll
|
||||||
path = @site.in_source_dir(dir, entry)
|
path = @site.in_source_dir(dir, entry)
|
||||||
next if @entry_filter.symlink?(path)
|
next if @entry_filter.symlink?(path)
|
||||||
|
|
||||||
key = sanitize_filename(File.basename(entry, ".*"))
|
|
||||||
if File.directory?(path)
|
if File.directory?(path)
|
||||||
read_data_to(path, data[key] = {})
|
read_data_to(path, data[entry] = {})
|
||||||
else
|
else
|
||||||
|
key = sanitize_filename(File.basename(entry, ".*"))
|
||||||
data[key] = read_data_file(path)
|
data[key] = read_data_file(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
name: Dairy
|
||||||
|
products:
|
||||||
|
- name: cheese
|
||||||
|
price: 5.5
|
||||||
|
- name: milk
|
||||||
|
price: 2.75
|
|
@ -438,6 +438,21 @@ class TestSite < JekyllUnitTest
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "auto load yaml files in subdirectory with a period in the name" do
|
||||||
|
site = Site.new(site_configuration)
|
||||||
|
site.process
|
||||||
|
|
||||||
|
file_content = SafeYAML.load_file(File.join(
|
||||||
|
source_dir, "_data", "categories.01", "dairy.yaml"
|
||||||
|
))
|
||||||
|
|
||||||
|
assert_equal site.data["categories.01"]["dairy"], file_content
|
||||||
|
assert_equal(
|
||||||
|
site.site_payload["site"]["data"]["categories.01"]["dairy"],
|
||||||
|
file_content
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
should "load symlink files in unsafe mode" do
|
should "load symlink files in unsafe mode" do
|
||||||
site = Site.new(site_configuration("safe" => false))
|
site = Site.new(site_configuration("safe" => false))
|
||||||
site.process
|
site.process
|
||||||
|
|
Loading…
Reference in New Issue