Skip to content

Implement pagination feature #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ group :jekyll_plugins do
gem "github-pages"
gem "jekyll-remote-theme"
gem "jekyll-feed"
gem "jekyll-paginate"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ DEPENDENCIES
github-pages
jekyll
jekyll-feed
jekyll-paginate
jekyll-remote-theme
jemoji
tzinfo-data
Expand Down
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ plugins:
- jemoji
- jekyll-feed
- jekyll-sitemap
- jekyll-paginate
# - jekyll-seo-tag
# - jekyll-redirect-from
# - jekyll-remote-theme
Expand Down Expand Up @@ -111,3 +112,6 @@ defaults:
# Set to `true` to show excerpts on the homepage.
#
show_excerpts: true

paginate: 5
paginate_path: "/blog/page:num/"
27 changes: 17 additions & 10 deletions _includes/posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,28 @@ <h3>
</div>

{% if site.paginate %}
<div class="pager">
<ul class="pagination">
<div class="pagination">
{%- if paginator.previous_page %}
<li><a href="{{ paginator.previous_page_path | relative_url }}" class="previous-page">{{ paginator.previous_page }}</a></li>
<a href="{{ paginator.previous_page_path | relative_url }}" class="prev">&larr; Prev</a>
{%- else %}
<li><div class="pager-edge">β€’</div></li>
<span class="disabled prev">&larr; Prev</span>
{%- endif %}
<li><div class="current-page">{{ paginator.page }}</div></li>

{%- for page in (1..paginator.total_pages) %}
{%- if page == paginator.page %}
<span class="current">{{ page }}</span>
{%- else %}
<a href="{{ paginator.previous_page_path | relative_url | replace: paginator.page, page }}" class="page">{{ page }}</a>
{%- endif %}
{%- endfor %}

{%- if paginator.next_page %}
<li><a href="{{ paginator.next_page_path | relative_url }}" class="next-page">{{ paginator.next_page }}</a></li>
<a href="{{ paginator.next_page_path | relative_url }}" class="next">Next &rarr;</a>
{%- else %}
<li><div class="pager-edge">β€’</div></li>
<span class="disabled next">Next &rarr;</span>
{%- endif %}
</ul>
</div>
{%- endif %}

{%- endif -%}
{%- endif %}

{%- endif -%}
35 changes: 35 additions & 0 deletions assets/css/bpd.css
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,38 @@ ul.speaking-list {
max-width: 60%;
}
}

.pagination {
display: flex;
gap: 10px;
justify-content: center;
align-items: center;
}

.pagination a {
text-decoration: none;
padding: 5px 10px;
border: 1px solid #ddd;
border-radius: 4px;
color: #007acc;
}

.pagination a:hover {
background-color: #007acc;
color: #fff;
}

.pagination .current {
padding: 5px 10px;
border: 1px solid #007acc;
background-color: #007acc;
color: white;
border-radius: 4px;
}

.pagination .disabled {
padding: 5px 10px;
border: 1px solid #ddd;
color: #aaa;
cursor: not-allowed;
}
11 changes: 0 additions & 11 deletions blog.md

This file was deleted.

8 changes: 8 additions & 0 deletions blog/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: default
lang: en
title: Blog
list_title: Posts
---

<div class="posts">{%- include posts.html -%}</div>
5 changes: 1 addition & 4 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ def test_mailto_bpdevs(page_url: tuple[Page, str]) -> None:

@pytest.mark.parametrize(
"url",
(
"/",
"/blog",
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this from our test case as it was causing the test to fail. The homepage no longer includes posts/blogs according to the latest changes and updates.

("/blog",),
)
def test_page_description_in_index_and_blog(page_url: tuple[Page, str], url: str):
"""Checks for the descriptions data in the blog posts. There should be some objects with the class `post-description`"""
Expand Down
Loading