Add pagination to blog posts
Implemented pagination in the blog to display 3 posts per page. This change allows users to navigate through posts using a pagination control at the bottom of the page. The pagination follows the pattern: << < 1 2 3 ... n > >>, enabling navigation to the first, previous, specific, next, or last pages. This improves user experience by preventing long scrolls on pages with many posts. Issue ID: FLAS-33
This commit is contained in:
parent
3b04a2b18b
commit
8e63ba89db
2 changed files with 29 additions and 1 deletions
|
|
@ -25,5 +25,24 @@
|
|||
<hr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<div class="pagination">
|
||||
{% if page > 1 %}
|
||||
<a href="{{ url_for('blog.index', page=1) }}"><<</a>
|
||||
<a href="{{ url_for('blog.index', page=page-1) }}"><</a>
|
||||
{% endif %}
|
||||
{% for p in range(1, total_pages + 1) %}
|
||||
{% if p == page %}
|
||||
<strong>{{ p }}</strong>
|
||||
{% else %}
|
||||
<a href="{{ url_for('blog.index', page=p) }}">{{ p }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if page < total_pages %}
|
||||
<a href="{{ url_for('blog.index', page=page+1) }}">></a>
|
||||
<a href="{{ url_for('blog.index', page=total_pages) }}">>></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', filename='collapse.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue