Skip to content

[feature] pagination for posts summary #234

@kwladyka

Description

@kwladyka

Currently there is a way to do prev / next but not 0, 1, 2, ...

    <div id="prev-next">
        {% if prev-uri %}
        <a class="button left" href="{{prev-uri}}">&laquo; Prev</a>
        {% endif %}
        {% if next-uri %}
        <a class="button right" href="{{next-uri}}">Next &raquo;</a>
        {% endif %}
    </div>

I would like to add numbers between prev and next like in the example below.
image

To make it possible we need to add data to Selmer with page index, URL, is page active.

Here is a Hugo example:

{{ if gt $paginator.TotalPages 1 }}
<nav>
    <ul class="pagination justify-content-center" style="flex-wrap: wrap">
        <li class="page-item{{ if not $paginator.HasPrev }} disabled {{ end }}">
            <a class="page-link" href="{{ if $paginator.HasPrev }}{{ $paginator.Prev.URL }}{{ end }}">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>
        {{ range .Paginator.Pagers }}
        <li class="page-item{{ if eq . $paginator }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
        {{ end }}
        <li class="page-item{{ if not $paginator.HasNext }} disabled {{ end }}">
            <a class="page-link" href="{{ if $paginator.HasNext }}{{ $paginator.Next.URL }}{{ end }}">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>
{{ end }}

This is the part which Cryogen doesn't have:

        {{ range .Paginator.Pagers }}
        <li class="page-item{{ if eq . $paginator }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
        {{ end }}

So we need something in that taste.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions