Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose collection static files via site.static_files #8961

Merged
merged 2 commits into from
Mar 24, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/jekyll/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def read
read_static_file(file_path, full_path)
end
end
site.static_files.concat(files) unless files.empty?
sort_docs!
end

Expand Down
9 changes: 8 additions & 1 deletion lib/jekyll/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ def docs_to_write
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
Expand All @@ -353,7 +360,7 @@ def documents
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
Expand Down
9 changes: 9 additions & 0 deletions test/test_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,13 @@ def convert(*_args)
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