diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 5ad896b2..fb024fa9 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -109,7 +109,7 @@ module Jekyll sanitized_path = sanitize_path(path) if rel_scope_path.include?("*") - glob_scope(sanitized_path, rel_scope_path) + File.fnmatch?(strip_collections_dir(rel_scope_path), sanitized_path) else path_is_subpath?(sanitized_path, strip_collections_dir(rel_scope_path)) end diff --git a/test/source/gathering/_staff/admins/backend/gamma.svg b/test/source/gathering/_staff/admins/backend/gamma.svg new file mode 100644 index 00000000..861641a7 --- /dev/null +++ b/test/source/gathering/_staff/admins/backend/gamma.svg @@ -0,0 +1 @@ + diff --git a/test/source/gathering/_staff/admins/backend/jack.md b/test/source/gathering/_staff/admins/backend/jack.md new file mode 100644 index 00000000..d6e5c2a9 --- /dev/null +++ b/test/source/gathering/_staff/admins/backend/jack.md @@ -0,0 +1,3 @@ +--- +speciality: Ruby +--- diff --git a/test/source/gathering/_staff/admins/frontend/alpha.svg b/test/source/gathering/_staff/admins/frontend/alpha.svg new file mode 100644 index 00000000..861641a7 --- /dev/null +++ b/test/source/gathering/_staff/admins/frontend/alpha.svg @@ -0,0 +1 @@ + diff --git a/test/source/gathering/_staff/admins/frontend/john.md b/test/source/gathering/_staff/admins/frontend/john.md new file mode 100644 index 00000000..cff8a6a4 --- /dev/null +++ b/test/source/gathering/_staff/admins/frontend/john.md @@ -0,0 +1,3 @@ +--- +speciality: JS Frameworks +--- diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index 9b7f1b68..32180aae 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -25,10 +25,6 @@ class TestFrontMatterDefaults < JekyllUnitTest assert_equal "val", @affected.data["key"] assert_nil @not_affected.data["key"] end - - should "not call Dir.glob block" do - refute_includes @output, "Globbed Scope Path:" - end end context "A site with full front matter defaults (glob)" do @@ -53,9 +49,38 @@ class TestFrontMatterDefaults < JekyllUnitTest assert_equal "val", @affected.data["key"] assert_nil @not_affected.data["key"] end + end - should "call Dir.glob block" do - assert_includes @output, "Globbed Scope Path:" + context "A site with collections and front matter defaults with glob patterns" do + setup do + site = fixture_site( + "collections_dir" => "gathering", + "collections" => { "staff" => { "output" => true } }, + "defaults" => [ + { + "scope" => { "path" => "_staff/**/*.md", "type" => "staff" }, + "values" => { "layout" => "simple" }, + }, + { + "scope" => { "path" => "_staff/**/*.svg" }, + "values" => { "css_class" => "epilson" }, + }, + ] + ) + site.read + @staff = site.collections["staff"] + end + + should "affect the appropriate items only" do + @staff.docs.each do |item| + assert_equal "simple", item.data["layout"] + assert_nil item.data["css_class"] + end + + @staff.files.each do |item| + assert_equal "epilson", item.data["css_class"] + assert_nil item.data["layout"] + end end end