Static files sourced from a collection do not get written

I’m trying to write a simple plugin that turns directories in a collection into HTML pages. The directory structure for such a collection looks a bit like this:

_projects
└── foo
    ├── 01.jpg
    ├── 02.jpg
    ├── 03.jpg
    └── index.md

with the collection set to output: false.

I would now like to transform this into output like this:

_site
└── projects
    └── foo
        ├── 01
        │   ├── 01.jpg
        │   └── index.html
        ├── 02
        │   ├── 02.jpg
        │   └── index.html
        ├── 03
        │   ├── 03.jpg
        │   └── index.html
        └── index.html

To do so I created a Generator subclass like this:

  class ProjectPageGenerator < Jekyll::Generator
    safe true

    def generate(site)
      collection = site.collections['projects']

      collection.files.each do |file|
        site.static_files << file
        site.pages << ImagePage.new(site, file)
      end
      
      collection.docs.each do |doc|
        site.pages << ProjectPage.new(site, doc)
      end
    end
  end

where ImagePage and ProjectPage create the HTML files, which works as expected.

What I am failing at is having the image files being copied over to _site. I tried adding the file instances from the collection (like in the example code) as well as manually constructing new instances. However I never come to a point where files are being copied to the desired location. What is the expected way of creating files from collections in a generator plugin?

Hello @m90,
Based on the generator plugin you have posted, don’t you think the static files in your “projects” would need a custom class as well to follow the custom behavior as implemented by your ImagePage and ProjectPage classes, especially since the collection’s metadata contains "output" => false?

I’m not sure? How would I use the default behavior of collections to generate a page per image. I.e. on a conceptual level, I’d have to add front matter to my images, else they’ll just get copied instead of rendered.