Using jekyll postfiles plugin for collections

I’m using a plugin named jekyll postfiles to handle assets beside my docs. The problem is that this plugin currently only supports posts. And I want to also use the same approach for my collections. With a little research I found that posts are also a kind of collection. And all posts and collection docs can be accessed by

`site.collections`

which is organized in the following manner:

{
  "posts" => # < Jekyll::Collection @label = posts docs = [All Posts are here] > , "myfirstcollection" => # < Jekyll::Collection @label = myfirstcollection docs = [All myfirstcollection docs are here] >
}

I realize that in this plugin, there is a loop to iterate all post docs :

  site.posts.docs.each do |post|
    copy_post_files(post)
  end

Now I think with a little tweak here we can also handle collection docs. However I have no experience with ruby and I don’t know what to do.

any Idea?

Given that you have a copy_collection_files function defined, you can to the same accessing site.collections.docs

site.collections.docs.each do | collection |
 copy_collection_files(collection)
end

Yes. I already have done it and its working. However there is still a problem that I discussed here. The problem is that jekyll core also transfer collection files, but to a diffrent place. And now I have too many duplicate files in my website.

Hi hnaseri, maybe too late to reply but I think you can set collections to not automatically generate pages in the _config.yml file.

I’ve been trying to access collections from a plugin.You post has given me an idea.