10000 Restore globbed path behavior in front matter defaults by ashmaroli · Pull Request #9762 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Restore globbed path behavior in front matter defaults #9762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jekyll/frontmatter_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def 10000 applies_path?(scope, path)
sanitized_path = sanitize_path(path)

if rel_scope_path.include?("*")
File.fnmatch?(strip_collections_dir(rel_scope_path), sanitized_path)
glob_scope(sanitized_path, rel_scope_path)
else
path_is_subpath?(sanitized_path, strip_collections_dir(rel_scope_path))
end
Expand Down
1 change: 0 additions & 1 deletion test/source/gathering/_staff/admins/backend/gamma.svg

This file was deleted.

3 changes: 0 additions & 3 deletions test/source/gathering/_staff/admins/backend/jack.md

This file was deleted.

1 change: 0 additions & 1 deletion test/source/gathering/_staff/admins/frontend/alpha.svg

This file was deleted.

3 changes: 0 additions & 3 deletions test/source/gathering/_staff/admins/frontend/john.md

This file was deleted.

37 changes: 6 additions & 31 deletions test/test_front_matter_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ 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
Expand All @@ -49,38 +53,9 @@ class TestFrontMatterDefaults < JekyllUnitTest
assert_equal "val", @affected.data["key"]
assert_nil @not_affected.data["key"]
end
end

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
should "call Dir.glob block" do
assert_includes @output, "Globbed Scope Path:"
end
end

Expand Down
0