Expose collection static files via `site.static_files` (#8961)

Merge pull request 8961
This commit is contained in:
Ashwin Maroli 2022-03-24 21:35:58 +05:30 committed by GitHub
parent 79869e7225
commit 9d86974e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -65,6 +65,7 @@ module Jekyll
read_static_file(file_path, full_path)
end
end
site.static_files.concat(files) unless files.empty?
sort_docs!
end

View File

@ -343,6 +343,13 @@ module Jekyll
documents.select(&:write?)
end
# Get the to be written static files
#
# Returns an Array of StaticFiles which should be written
def static_files_to_write
static_files.select(&:write?)
end
# Get all the documents
#
# Returns an Array of all Documents
@ -353,7 +360,7 @@ module Jekyll
end
def each_site_file
%w(pages static_files docs_to_write).each do |type|
%w(pages static_files_to_write docs_to_write).each do |type|
send(type).each do |item|
yield item
end

View File

@ -735,4 +735,13 @@ class TestSite < JekyllUnitTest
end
end
end
context "static files in a collection" do
should "be exposed via site instance" do
site = fixture_site("collections" => ["methods"])
site.read
assert_includes site.static_files.map(&:relative_path), "_methods/extensionless_static_file"
end
end
end