jekyll-category-archive-plugin icon indicating copy to clipboard operation
jekyll-category-archive-plugin copied to clipboard

Jekyll 3.0 - Deprecations

Open SteveEdson opened this issue 9 years ago • 5 comments

Sorry if this is a known issue, but since Jekyll 3.0, the following warnings appear:

Deprecation: Collection#each should be called on the #docs array directly.
                    Called by /home/rof/src/bitbucket.org/SteveEdson/steveedson/_plugins/category_archive_plugin.rb:38:in `posts_group_by_category'.
       Deprecation: Document#categories is now a key in the #data hash.
                    Called by /home/rof/src/bitbucket.org/SteveEdson/steveedson/_plugins/category_archive_plugin.rb:38:in `block in posts_group_by_category'.

Thanks.

SteveEdson avatar Oct 27 '15 09:10 SteveEdson

Hi. I haven't tested with Jekyll 3.0. Thus there must be some compatibility. I, of course, need to upgrade to 3.0. Will look into the issue possibly later this week.

shigeya avatar Oct 27 '15 23:10 shigeya

Yeah there's no rush. Everything appears to be working fine, it's just throwing deprecation warnings.

Thanks

SteveEdson avatar Oct 28 '15 11:10 SteveEdson

Hello did this ever get sorted out as Im stuck upgrading a plugin.

I have added docs to site.posts.docs.each for Jekyll 3 but "categories.each" still break

def posts_group_by_category(site)
  category_map = {}
  site.posts.docs.each do |p|
    p.categories.each do |c|
      (category_map[c] ||= []) << p
    end
  end
  category_map
end

themestechnology avatar Jan 18 '16 08:01 themestechnology

It looks like this has been fixed in PR #17 although that PR hasn't been merged yet. I am using the Phlow Feeling Responsive theme, which uses jekyll-paginate and Jekyll 3, so I had this same issue. PR #17 fixes this issue for me.

modulitos avatar Feb 07 '16 09:02 modulitos

The solution was p['categories'].each for me

  def posts_group_by_category(site)
      category_map = {}
      site.posts.docs.each do |p|
        p['categories'].each do |c|
          (category_map[c] ||= []) << p
        end
      end
      category_map
    end

themestechnology avatar Feb 09 '16 08:02 themestechnology