sverrirs / jekyll-paginate-v2

Pagination Generator for Jekyll 3 (enhanced replacement for the old built-in jekyll-paginate gem) ⛺
https://rubygems.org/gems/jekyll-paginate-v2
MIT License
524 stars 289 forks source link

Pagination leaving a blank spot #224

Closed tylermanning closed 3 years ago

tylermanning commented 3 years ago

I setup the v2 pagination as described in the tutorial, cleared old gemfile.lock and rebuilt the site. Everything works as expected except for one odd issue. My settings are set to have 9 blog posts per page but it is making 8 on the first page, leaving a blank spot for the 9th. Then doing it correctly on page 2. This never happened with the old plugin and i didn’t change anything besides the _config.yml and gem file.

Here are my settings: _config.yml:

plugins:
  - jekyll-feed
  - jekyll-sitemap
  - jekyll-seo-tag
  - jekyll-paginate-v2

# Pagination Settings
pagination:
  enabled: true
  per_page: 9
  permalink: '/page:num/'
  title: ' - page :num'
  limit: 0
  sort_field: 'post-priority'
  sort_reverse: false
  debug: true

gem file:

source "https://rubygems.org"
gem 'github-pages'
gem 'jekyll-sitemap'
gem 'jekyll-paginate-v2'
tylermanning commented 3 years ago

I found out the reason why there is a blank spot only on the first page. I forgot i have a highlighted post at the top that is different from the rest so it counts in the paginator counter. So i thought setting the offset of the plugin to 1 would solve it but it didn't do anything :thinking:

Here is the start of my index.html that involves the highlighted post:

---
layout: default
pagination: 
  enabled: true
---
<div class="page-content">
  <div class="mdl-grid">

 {% assign sortedPosts = paginator.posts | sort: 'post-priority' %}

  {% if site.post_type == 'highlight' %}

    {% for post in sortedPosts %}
    {% if post.highlight %}
    <div class="section-highlight section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">

      <header class="section__play-btn mdl-cell mdl-cell--3-col-desktop mdl-cell--2-col-tablet mdl-cell--4-col-phone" {% if post.image %} style="background: url('{{ post.image }}') center/cover;" {% endif %}></header>

      <div class="mdl-card mdl-cell mdl-cell--9-col-desktop mdl-cell--6-col-tablet mdl-cell--4-col-phone">
        <div class="mdl-card__supporting-text">
          <h4>{{ post.title }}</h4>
          <p>{{ post.excerpt }}</p>
        </div>
        <div class="mdl-card__actions">
          <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" href="{{ post.url | prepend: site.baseurl }}">Read More</a>
        </div>
      </div>
      ...
tylermanning commented 3 years ago

The offset just seems to omit the final post(s) according to its value. I thought offset=1 would ignore the first post and start counting from the second one.

tylermanning commented 3 years ago

I found a workaround, kinda hacky but it does what i need. Moved the highlighted post out of the paginator logic and disabled pagination on it, however it only shows on page 1 so added a conditional for that.