summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2024-02-25 22:35:49 -0600
committerHombreLaser <sebastian-440@live.com>2024-02-25 22:35:49 -0600
commitadb6f7e9e73716e58529d96540f204e5e0825179 (patch)
tree3af590f566b58e437e17b18260e49b0f4d7fe07b /templates
parenta15ebd2f300cfc6a0b26c94cb1b2a01f672718e9 (diff)
Add pagination macro
Diffstat (limited to 'templates')
-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