pagination.twig 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {% if posts.pagination.pages is not empty %}
  2. <nav class="pagination-block">
  3. <ul class="pagination">
  4. {# First #}
  5. {% if posts.pagination.pages|first and posts.pagination.pages|first.current != true %}
  6. <li class="first btn">
  7. <a href="{{ posts.pagination.pages|first.link }}">First</a>
  8. </li>
  9. {% else %}
  10. <li class="first btn disabled">
  11. <button disabled>First</button>
  12. </li>
  13. {% endif %}
  14. {# Previous #}
  15. {% if posts.pagination.prev %}
  16. <li class="prev btn">
  17. <a href="{{ posts.pagination.prev.link }}">Previous</a>
  18. </li>
  19. {% else %}
  20. <li class="prev btn disabled">
  21. <button disabled>Previous</button>
  22. </li>
  23. {% endif %}
  24. {# Pages #}
  25. {% for page in posts.pagination.pages %}
  26. {% if page.link %}
  27. <li>
  28. <a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
  29. </li>
  30. {% else %}
  31. <li class="current">
  32. <span class="{{ page.class }}">{{ page.title }}</span>
  33. </li>
  34. {% endif %}
  35. {% endfor %}
  36. {# Next #}
  37. {% if posts.pagination.next %}
  38. <li class="next btn">
  39. <a href="{{ posts.pagination.next.link }}">Next</a>
  40. </li>
  41. {% else %}
  42. <li class="next btn disabled">
  43. <button disabled>Next</button>
  44. </li>
  45. {% endif %}
  46. {# Last #}
  47. {% if posts.pagination.pages|last and posts.pagination.pages|last.current != true %}
  48. <li class="last btn">
  49. <a href="{{ posts.pagination.pages|last.link }}">Last</a>
  50. </li>
  51. {% else %}
  52. <li class="last btn disabled">
  53. <button disabled>Last</button>
  54. </li>
  55. {% endif %}
  56. </ul>
  57. </nav>
  58. {% endif %}