Skip to content
Snippets Groups Projects
pagination.html 1.79 KiB
Newer Older
  • Learn to ignore specific revisions
  • Tom Wiesing's avatar
    Tom Wiesing committed
    {% comment %}
        Renders a pagination element. 
        Expects the default jekyll 'paginator' as argument. 
    {% endcomment %}
    
    <ul class="pagination">
        
        <!-- The previous page -->
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
        {% if paginator.previous_page %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
            <li class="waves-effect">
                <a href="{{ site.baseurl }}{{paginator.previous_page_path}}">
                    <i class="material-icons">chevron_left</i>
                </a>
            </li>
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
        {% else %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
            <li class="disabled">
                <a href="#!">
                    <i class="material-icons">chevron_left</i>
                </a>
            </li>
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
        {% endif %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        
        <!-- Show all the pages -->
        {% for page in (1..paginator.total_pages) %}
            {% if page == paginator.page %}
                <li class='active'>
                    <a href="#!">
                        {{page}}
                    </a>
                </li>
            {% elsif page == 1 %}
                <li class="waves-effect">
                    <a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">
                        {{page}}
                    </a>
                </li>
            {% else %}
                <li class="waves-effect">
                    <a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">
                        {{page}}
                    </a>
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
                </li>
            {% endif %}
        {% endfor %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        
        
        <!-- The next page -->
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
        {% if paginator.next_page %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
            <li class="waves-effect">
                <a href="{{ site.baseurl }}{{paginator.next_page_path}}">
                    <i class="material-icons">chevron_right</i>
                </a>
            </li>
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
        {% else %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
            <li class="disabled">
                <a href="#!">
                    <i class="material-icons">chevron_right</i>
                </a>
            </li>
    
    Michael Kohlhase's avatar
    Michael Kohlhase committed
        {% endif %}