Skip to content

Expose collection static files via site.static_files#8961

Merged
jekyllbot merged 2 commits intojekyll:masterfrom
ashmaroli:hoist-collection-staticfiles
Mar 24, 2022
Merged

Expose collection static files via site.static_files#8961
jekyllbot merged 2 commits intojekyll:masterfrom
ashmaroli:hoist-collection-staticfiles

Conversation

@ashmaroli
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@ashmaroli ashmaroli requested review from mattr- and parkr February 10, 2022 06:05
@parkr
Copy link
Copy Markdown
Member

parkr commented Feb 11, 2022

Nice, clean implementation. Well done, @ashmaroli!

@ashmaroli
Copy link
Copy Markdown
Member Author

ping @mattr- for a re-review.

1 similar comment
@ashmaroli
Copy link
Copy Markdown
Member Author

ping @mattr- for a re-review.

@ashmaroli
Copy link
Copy Markdown
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