jekyll / jekyll-paginate

NO LONGER UNDER ACTIVE DEVELOPMENT as of Jekyll 3: Pagination Generator for Jekyll
MIT License
110 stars 84 forks source link

Paginate Collections #3

Closed parkr closed 9 years ago

parkr commented 10 years ago

Allow users to paginate collections!

rachelnabors commented 10 years ago

Voting yay on this.

sarhov commented 10 years ago

+1

jeromecoupe commented 10 years ago

+1 pretty please. One of my biggest frustrations with Jekyll would be solved by this. In most cases You can do without pagination but sometimes it would be quite handy (ton of content)

parkr commented 10 years ago

Thanks for the +1's. How would you envision pagination working?

binoyte commented 10 years ago

+1 for that definitly! +1 for paginate categories

TooGz commented 10 years ago

Vote for it :)

kleinfreund commented 10 years ago

:+1:

jeromecoupe commented 10 years ago

As far as the technical implementation, I don't have a clue but, since pagination should ideally be available in multiple places (posts, collections, categories), I guess you'd have to go beyond the existing paginator variable.

Ideally (and this is probably very difficult to implement), I'd like a looping tag pair that you could then use with any array / object (post / collections / categories). Something along the lines of:

provided you have an _albums collection

{% paginate site.albums as albums limit:5 %}

  {% for album in albums %}
    ... display album data ...
  {% endfor %}

  {% if paginate.previous %}
    <a href="{{ paginate.previous_path | prepend: site.baseurl | replace: '//', '/' }}">Previous</a>
  {% endif %}

  {% if paginate.next %}
    <a href="{{ paginate.next_path | prepend: site.baseurl | replace: '//', '/' }}">Next</a>
  {% endif %}

{% endpaginate %}
ziyan-junaideen commented 9 years ago

I agree with @jeromecoupe. Great idea :+1: . Can try to give some help my self but will take time because I am just 2 days old for Jekyll

garethredfern commented 9 years ago

Would love to see this.

sambaldwin commented 9 years ago

:+1: I would also love to see this.

marianoviola commented 9 years ago

:+1: sounds good.

parkr commented 9 years ago

Happy to look at a PR :)

sambaldwin commented 9 years ago

Not sure if this is too off-topic, but since I arrived here via Google looking for a solution to collection pagination, I figured I'd post a workaround incase anyone else was in the same boat as me.

It is possible to manually paginate using both limit and offset on the for loop.

My code:

{% for item in items limit:10 %}

And then in a manually created page-2.html file:

{% for item in items limit:10 offset:10 %}

page-3.html:

{% for item in items limit:10 offset:20 %}

etc.

swashcap commented 9 years ago

:+1:

daveaseeman commented 9 years ago

+1 for the solution proposed by @jeromecoupe (kudos to @sambaldwin for an easy work-around but I'm 100% in favor of making this a more universal feature)

bjfish commented 9 years ago

:+1:

rachelnabors commented 9 years ago

:+1:

jorgebg commented 9 years ago

:+1:

rhewitt22 commented 9 years ago

:+1:

TWiStErRob commented 9 years ago

@parkr why was this closed? Where's the work on collection pagination, if any, being tracked in future?

stammy commented 9 years ago

Add me as interested in this as well :)

rachelnabors commented 9 years ago

And me.

sarhov commented 9 years ago

I also didn't understand why the issue is closed ...

gynter commented 9 years ago

Because jekyll-paginate will be discontinued, more info in forum.

TWiStErRob commented 9 years ago

Thanks @gynter, please note that the issue was closed a month ago, while that announcement was done 10 hours ago. So it's clear now it, but we can agree it was a weird timeline of communication. It would be nice to update the README.md with a deprecation notice with a link to that forum and later a link to replacement, thanks again!

Fallenstedt commented 7 years ago

You can include pagination by including some liquid logic into the layout of your collection. For example, I have a collection called "_portfolios" where I will hold all of my portfolio items. Each portfolio item has yml like this:

`--- title: Landscape subtitle: Photography layout: portfolio

cta: btnText: View Services btnType: btn-warning btnLink: /about/

images:

In layouts > portfolio.html I have the following includes to use a widget I made:

{% include collection-pagination.html collection="portfolios" %}

The liquid logic in collection-pagination.html is:

` {% assign this_collection = include.collection %} {% for c in site.[this_collection] %} {% if c.title == page.title %} {% assign thisPost = c %} {% if forloop.index == 1 %} {% assign prevflag = 0 %} {% assign nextflag = 1 %} {% elsif forloop.index == forloop.length %} {% assign prevflag = 1 %} {% assign nextflag = 0 %} {% else %} {% assign prevflag = 1 %} {% assign nextflag = 1 %} {% endif %} {% endif %} {% endfor %}

{% for c in site.[this_collection] %} {% if c.title == page.title %} {% assign prevflag = 0 %} {% endif %} {% if prevflag == 1 %} {% assign prevPost = c %} {% assign page.previous = c %} {% endif %} {% endfor %}

{% if nextflag == 1 %} {% for c in site.[this_collection] %} {% if foundPost == 1 %} {% assign getNext = 1 %} {% endif %} {% if c.title == page.title %} {% assign foundPost = 1 %} {% endif %} {% if getNext == 1%} {% assign nextPost = c %} {% assign page.next = c %} {% assign foundPost = 0 %} {% assign getNext = 0 %} {% endif %} {% endfor %} {% endif %}

{% if prevPost.url %} previous {% endif %}

{% if nextPost.url %} next {% endif %}

`

This generate two buttons that you can style. The neat part is that if you are at the first item of the collection, the "previous" button will be disabled and hidden. If you are at the last item of a collection, the "next" button will be disabled.

I learned about this from: anjesh.github.io/2015/01/25/collection-pagination-working-github-pages/

wysiwyggins commented 5 years ago

I've been trying to paginate a masonry layout image-board that iterates through every file in an image folder and it feels way more complicated than it should be... I've been using paginate v2

ashmaroli commented 5 years ago

@weevil Paginate v2 is a different project entirely: https://github.com/sverrirs/jekyll-paginate-v2