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?