Help needed to paginate highly filtered collection


#1

I’m building an ICO Website. The website contains a ‘coins’ collection, this collection contains all the ico coin pages. I have then created pages such as https://moonlandingnetwork.netlify.com/upcomingico , https://moonlandingnetwork.netlify.com/activeico etc to display these coins based on whether they are upcoming, active or ended. I used this code to filter these coins based on the date and based on whether the coin is featured.

{% assign featuredcoins = site.coins | where: ‘ico.featured’, ‘true’ %}
{% assign regularcoins = site.coins | where: ‘ico.featured’, ‘false’ %}
{% assign timeframe = 86400 %}
{% assign current_date = “now” | date: “%s” | minus: timeframe %}

{% assign featuredUpcoming = “” | split: ‘,’ %}
{% for coin in featuredcoins %}
{% assign pre_ico_end_date = coin.pre-ico.end-date | date: “%s” | plus: 0 %}
{% assign ico_start_date = coin.ico-detail.start-date | date: “%s” | plus: 0 %}
{% if current_date > pre_ico_end_date and ico_start_date > current_date %}
{% assign featuredUpcoming = featuredUpcoming | push: coin %}
{% endif %}
{% endfor %}

{% assign regularUpcoming = “” | split: ‘,’ %}
{% for coin in regularcoins %}
{% assign pre_ico_end_date = coin.pre-ico.end-date | date: “%s” | plus: 0 %}
{% assign ico_start_date = coin.ico-detail.start-date | date: “%s” | plus: 0 %}
{% if current_date > pre_ico_end_date and ico_start_date > current_date %}
{% assign regularUpcoming = regularUpcoming | push: coin %}
{% endif %}
{% endfor %}

{% for coin in featuredUpcoming limit: 2 %}

  • Featured Coin
  • {% endfor %}

    {% for coin in regularUpcoming %}

  • Regular Coin
  • {% endfor %}

    Where I’m stuck is I need to paginate this. I know jekyll doesn’t support pagination of collections. I came across Jekyll paginate V2, Octopress Paginate and this code gist.github .com/Phlow/5613fb3f18946f577f071e2a258749a3 in my research. But i couldn’t get any of those to work.

    I also require the pagination to work in such a way that the featured coins change on each new page along with the regular coins. Can somebody help me direct on what i should do.