Skip to content

Instantly share code, notes, and snippets.

@prashantgpt91
Last active May 3, 2020 08:39
Show Gist options
  • Save prashantgpt91/81c27631d34b6a69b7dabc1f68ce67df to your computer and use it in GitHub Desktop.
Save prashantgpt91/81c27631d34b6a69b7dabc1f68ce67df to your computer and use it in GitHub Desktop.
---
layout: default
---
{% assign posts = '' | split: '/' %}
{% for post in site.posts %}
{% if post.queued == null %}
{% assign posts = posts | push: post %}
{% endif %}
{% endfor %}
{% assign totalPages = site.posts | size | minus: 1 | divided_by: 9 %}
{% assign totalPagesRemainder = site.posts | size | minus: 1 | modulo: site.paginate %}
{% if totalPagesRemainder > 0 %}
{% assign totalPages = totalPages | plus: 1 %}
{% endif %}
<main id="main" role="main" class="main constrain" data-paginator-current="{{ paginator.page }}" data-paginator-total="{{ totalPages }}">
{% assign postsPerPage = site.paginate %}
{% if paginator.page == 1 %}
{% assign postsOffset = 0 %}
{% assign postsPerPage = postsPerPage | plus: 1 %}
{% else %}
{% assign postsOffset = paginator.page | minus: 1 | times: postsPerPage | plus: 1 %}
{% endif %}
{% for post in posts | offset: postsOffset | limit: postsPerPage %}
<div class="js-posts">
{% if forloop.first == true %}
{% if postsOffset == 0 %}
{% include partials/post-small.html post=post %}
{% endif %}
{% if postsOffset != 0 %}
{% include partials/post-small.html post=post index=forloop.index page=paginator.page %}
{% endif %}
{% else %}
{% include partials/post-small.html post=post index=forloop.index page=paginator.page %}
{% if forloop.last == true %}
</div>
{% endif %}
{% endif %}
{% endfor %}
</main>
{% include partials/paginator.html paginator=paginator %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment