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

Conversation

ashmaroli
Copy link
Member

  • This is a 馃檵 feature or enhancement.
  • I've added tests.

Summary

Jekyll::Site#static_files should expose all static files in the site. Even those static files read from within collections.

Context

Resolves #8901

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like cucumber is upset. Otherwise, LGTM!

@ashmaroli
Copy link
Member Author

Looks like cucumber is upset.

Site#documents contains both Collection#docs and Collection#files.
While Site#docs_to_write essentially yields a filtered array of writable collection items, Site#each_site_file includes Site#static_files in addition to Site#docs_to_write.

jekyll/lib/jekyll/site.rb

Lines 228 to 232 in 8690765

def write
Jekyll::Commands::Doctor.conflicting_urls(self)
each_site_file do |item|
item.write(dest) if regenerator.regenerate?(item)
end

jekyll/lib/jekyll/site.rb

Lines 355 to 356 in 8690765

def each_site_file
%w(pages static_files docs_to_write).each do |type|

jekyll/lib/jekyll/site.rb

Lines 342 to 344 in 8690765

def docs_to_write
documents.select(&:write?)
end

jekyll/lib/jekyll/site.rb

Lines 349 to 353 in 8690765

def documents
collections.each_with_object(Set.new) do |(_, collection), set|
set.merge(collection.docs).merge(collection.files)
end.to_a
end

Therefore, to maintain backwards-compatibility of Site#each_site_file, introduce Site#static_files_to_write

@parkr
Copy link
Member

parkr commented Feb 11, 2022

Nice, clean implementation. Well done, @ashmaroli!

@ashmaroli
Copy link
Member Author

ping @mattr- for a re-review.

1 similar comment
@ashmaroli
Copy link
Member Author

ping @mattr- for a re-review.

@ashmaroli
Copy link
Member Author

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit 9d86974 into jekyll:master Mar 24, 2022
jekyllbot added a commit that referenced this pull request Mar 24, 2022
@ashmaroli ashmaroli deleted the hoist-collection-staticfiles branch March 24, 2022 16:06
github-actions bot pushed a commit that referenced this pull request Mar 24, 2022
Ashwin Maroli: Expose collection static files via `site.static_files` (#8961)

Merge pull request 8961
@jekyll jekyll locked and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static files in collection not found in site.static_files
4 participants