feat: Add pagination to leaderboard
This commit is contained in:
1 parent
40b75f8178
commit
7844aeaba8
2 files changed
+24
-1
No files matched your search
@@ -72,7 +72,14 @@
|
|||||||
<!-- Users Grid for Merits - Week -->
|
<!-- Users Grid for Merits - Week -->
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
{% assign users = site.data.users %}
|
{% assign users = site.data.users %}
|
||||||
{% for user in users %}
|
{% assign users_per_page = 10 %}
|
||||||
|
{% assign current_page = page.current_page | default: 1 %}
|
||||||
|
{% assign total_pages = (users.size / users_per_page) | ceil %}
|
||||||
|
{% assign start_index = (current_page - 1) * users_per_page %}
|
||||||
|
{% assign end_index = start_index + users_per_page - 1 %}
|
||||||
|
{% assign paginated_users = users | slice: start_index, users_per_page %}
|
||||||
|
|
||||||
|
{% for user in paginated_users %}
|
||||||
<div class="font-action filter-btn w-full sm:w-auto flex space-x-2 p-3 border-2 border-gray-300 rounded-md hover:border-primary transition-colors cursor-pointer">
|
<div class="font-action filter-btn w-full sm:w-auto flex space-x-2 p-3 border-2 border-gray-300 rounded-md hover:border-primary transition-colors cursor-pointer">
|
||||||
<div class="flex items-center space-x-4">
|
<div class="flex items-center space-x-4">
|
||||||
<div>
|
<div>
|
||||||
@@ -86,6 +93,21 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Pagination Controls -->
|
||||||
|
<div class="flex justify-center mt-4">
|
||||||
|
{% if current_page > 1 %}
|
||||||
|
<a href="?page={{ current_page | minus: 1 }}" class="px-4 py-2 mx-1 bg-primary text-white rounded-md hover:bg-primary-dark">Previous</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for i in (1..total_pages) %}
|
||||||
|
<a href="?page={{ i }}" class="px-4 py-2 mx-1 {% if i == current_page %}bg-primary text-white{% else %}bg-gray-200 text-gray-700{% endif %} rounded-md hover:bg-primary-dark">{{ i }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if current_page < total_pages %}
|
||||||
|
<a href="?page={{ current_page | plus: 1 }}" class="px-4 py-2 mx-1 bg-primary text-white rounded-md hover:bg-primary-dark">Next</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
layout: default
|
layout: default
|
||||||
title: Leaderboard
|
title: Leaderboard
|
||||||
permalink: /leaderboard/
|
permalink: /leaderboard/
|
||||||
|
current_page: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
{% include leaderboard.liquid %}
|
{% include leaderboard.liquid %}
|
||||||
Reference in new issue
Block a user