summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--templates/comments/index.jinja3
-rw-r--r--templates/macros/pagination.jinja18
2 files changed, 21 insertions, 0 deletions
diff --git a/templates/comments/index.jinja b/templates/comments/index.jinja
index 4f082bd..217ddb3 100644
--- a/templates/comments/index.jinja
+++ b/templates/comments/index.jinja
@@ -1,3 +1,5 @@
+{% import 'macros/pagination.jinja' as pagination %}
+
<div id="comment-section" class="comment-section">
{% for comment in page.items %}
<div id="comment-{{comment.id}}" class="comment">
@@ -26,4 +28,5 @@
</section>
</div>
{% endfor %}
+ {{ pagination.render_pagination(page, 'comments.index') }}
</div>
diff --git a/templates/macros/pagination.jinja b/templates/macros/pagination.jinja
new file mode 100644
index 0000000..fdd8993
--- /dev/null
+++ b/templates/macros/pagination.jinja
@@ -0,0 +1,18 @@
+{% macro render_pagination(pagination, endpoint) %}
+ <div class=page-items>
+ {{ pagination.first }} - {{ pagination.last }} of {{ pagination.total }}
+ </div>
+ <div class=pagination>
+ {% for page in pagination.iter_pages() %}
+ {% if page %}
+ {% if page != pagination.page %}
+ <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a>
+ {% else %}
+ <strong>{{ page }}</strong>
+ {% endif %}
+ {% else %}
+ <span class=ellipsis>…</span>
+ {% endif %}
+ {% endfor %}
+ </div>
+{% endmacro %} \ No newline at end of file