octopress / paginate

A simple paginator for Jekyll sites.
MIT License
105 stars 37 forks source link

Deprecation errors using categories and category #35

Open egeis opened 8 years ago

egeis commented 8 years ago

Every time I specify a category in paginate I run across this error during building.

document#categories is now a key in the #data hash octopress-paginate.rb:148 in 'block in collection'

Using following settings:

layout: post
paginate:
  collection: posts
  category: general

After spending the last hour changing settings it seems to error out on both categories and category.

brandonb927 commented 8 years ago

I have migrated from jekyll-paginate to octopress-paginate and I seem to be running into this issue as well. I don't know ruby well enough to submit a PR so any help would be great!

egeis commented 7 years ago

I managed to apply one of the pull requests changes to categories and tags to my own fork then use that in the gem file. I can finally see the errors im getting. Noticed this plugin does not function from a page that is generated from another generator....

straversi commented 7 years ago

Same for using the tag key: Document#tags is now a key in the #data hash.

jdesiloniz commented 7 years ago

It's happening to us too, after applying pagination to blog posts with categorization.

gluttonousbear commented 7 years ago

The same happens for me with github-pages. Neither Tags, nor Categories (or their singular) work. octopress-paginate is the only plugin I am using. I am building the site locally with Ruby and pushing the _site/ folder to github pages.

In its current form, octopress-paginate cannot do more for me than the basic Jekyll functionality.

I might try to use collections instead and report back whether or not that worked.

gluttonousbear commented 7 years ago

Update: The deprecation issue does not seem to appear when using collections. However, while the locally generated site paginates collections, the live github version will simply not accept any collection pagination. The interaction between github pages and octopress-paginate is definitely a strange one.

aprilmintacpineda commented 7 years ago

I just used this paginate plugin and I am encountering the same warning saying:

Deprecation: Document#categories is now a key in the #data hash.
Deprecation: Called by ["C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/document.rb:374:in `method_missing'"].

My code:

---
layout: default
page_title: how-tos
paginate: true
paginate:
  categories: [how-tos]
  collection: posts
  per_page: 1
  limit: false
  permalink: /:num/
---

<div class="post-list-container limited-width">
  {% for post in paginator.posts %}
    <article class="post load-defaults">
      <img src="/blog/public/post-resources/{{ post.cover_image }}">
      <header>
        <h1>{{ post.title }}</h1>
        <p><strong>Date posted:</strong> {{ post.date_posted | date: '%B, %d, %Y' }}</p>
        <p><strong>Category:</strong> {{ post.category }}</p>
      </header>
      <section>
        <p>{{ post.description }}</p>
        <p><a href="/blog{{ post.url }}">Read more</a></p>
      </section>
    </article>
  {% endfor %}

  <div class="pages">
    {% for i in (1..paginator.total_pages) %}
      {% if i == 1 %}
        {% if i == paginator.page %}
          <a class="onlink" href="/blog/category/how-tos/">{{ i }}</a>
        {% else %}
          <a href="/blog/category/how-tos/">{{ i }}</a>
        {% endif %}
      {% else %}
        {% if i == paginator.page %}
          <a class="onlink" href="/blog/category/how-tos/{{ i }}">{{ i }}</a>
        {% else %}
          <a href="/blog/category/how-tos/{{ i }}">{{ i }}</a>
        {% endif %}
      {% endif %}
    {% endfor %}
  </div>
</div>

Any updates about this?

aprilmintacpineda commented 7 years ago

Update: I just pushed my jekyll project on github, I think it was affected by the deprecation warning and now it doesn't show any post at all. In short, pagination does not work. It works on my local machine by the way.

https://aprilmintacpineda.github.io/blog/category/all/

aprilmintacpineda commented 7 years ago

For those looking to paginate their posts based on category, I suggest using the collection for now while the pagination by category is still encountering the error.

jhummel commented 6 years ago

Running into this same deprecation warning on paginating tags. It does finish the build, it's just a lot of terminal spam.

armcknight commented 6 years ago

I had the same problem and seem to have fixed it. Here is my usage before that presented the same problem as others describe here ("Document#categories is now a key in the #data hash.").

A sample collection item, before the fix:

---
index: 0
image_url: IMG_0045.jpg
description: "The drive to Big Bend."
thumbnail_url: IMG_0045-thumbnail.jpg
thumbnail_width: 150
date: October 24, 2017
album: 2017-10-24-big-bend-national-park
category: 2017-10-24-big-bend-national-park # <-- offending line
---

and after:

---
index: 0
image_url: IMG_0045.jpg
description: "The drive to Big Bend."
thumbnail_url: IMG_0045-thumbnail.jpg
thumbnail_width: 150
date: October 24, 2017
album: 2017-10-24-big-bend-national-park
# ↓ the proper usage
data:
  category: 2017-10-24-big-bend-national-park
---

And the page that was paginating items of this collection, before:

---
paginate:
  collection: photos
  category: 2017-10-24-big-bend-national-park # <-- offending line
  per_page: 1
  limit: false
  permalink: /:num/
---

and after:

---
paginate:
  collection: photos
  # ↓ start fix
  data:
    category: 201 2017-10-24-big-bend-national-park
  # ↑ end fix
  per_page: 1
  limit: false
  permalink: /:num/
---
armcknight commented 6 years ago

Sorry, but what I just posted doesn't actually work. It just caused a silent failure. At least it didn't show the deprecation warnings ;P

What I'd done prior to this is to separate out the deprecation warnings from console output to a file, which I checked in and then can at least see if there are changes in the deprecation messages if it gets dirtied in the git index: jekyll build 2>deprecations