From 32205be0815fcf5c61d3409c120307e25d94542f Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Thu, 26 Dec 2024 22:04:35 +0000 Subject: [PATCH 1/4] Implement pagination feature --- Gemfile | 1 + Gemfile.lock | 1 + _config.yml | 4 ++++ _includes/posts.html | 10 +++++----- blog.html | 8 ++++++++ blog.md | 11 ----------- 6 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 blog.html delete mode 100644 blog.md diff --git a/Gemfile b/Gemfile index c392852..3237b38 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 635b8d4..969b19c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -309,6 +309,7 @@ DEPENDENCIES github-pages jekyll jekyll-feed + jekyll-paginate jekyll-remote-theme jemoji tzinfo-data diff --git a/_config.yml b/_config.yml index a759cbc..29e04c4 100644 --- a/_config.yml +++ b/_config.yml @@ -60,6 +60,7 @@ plugins: - jemoji - jekyll-feed - jekyll-sitemap + - jekyll-paginate # - jekyll-seo-tag # - jekyll-redirect-from # - jekyll-remote-theme @@ -111,3 +112,6 @@ defaults: # Set to `true` to show excerpts on the homepage. # show_excerpts: true + +paginate: 5 +paginate_path: "/blog/page:num/" diff --git a/_includes/posts.html b/_includes/posts.html index 0227d1b..6543a4a 100644 --- a/_includes/posts.html +++ b/_includes/posts.html @@ -1,8 +1,8 @@ -{% if site.paginate %} + {%- if posts.size > 0 -%} {%- if page.list_title -%} @@ -29,7 +29,7 @@

{%- endfor -%} - {% if site.paginate %} + -{%- endif -%} +{%- endif -%} diff --git a/blog.html b/blog.html new file mode 100644 index 0000000..7b6f5f1 --- /dev/null +++ b/blog.html @@ -0,0 +1,8 @@ +--- +layout: default +lang: en +title: Blog +list_title: Posts +--- + +
{%- include posts.html -%}
diff --git a/blog.md b/blog.md deleted file mode 100644 index 9caac8c..0000000 --- a/blog.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -layout: default -lang: en -title: Blog -permalink: /blog/ -list_title: Posts ---- - -
- {%- include posts.html -%} -
From 7c03b1996407df314dcca8fd9c3b01fbd9490760 Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 27 Dec 2024 08:55:30 +0000 Subject: [PATCH 2/4] implement pagination for blog --- _includes/posts.html | 8 ++++---- blog.html => blog/index.html | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename blog.html => blog/index.html (100%) diff --git a/_includes/posts.html b/_includes/posts.html index 6543a4a..583964f 100644 --- a/_includes/posts.html +++ b/_includes/posts.html @@ -1,8 +1,8 @@ - +{% endif %} {%- if posts.size > 0 -%} {%- if page.list_title -%} @@ -29,7 +29,7 @@

{%- endfor -%} - + {%- endif %} {%- endif -%} diff --git a/blog.html b/blog/index.html similarity index 100% rename from blog.html rename to blog/index.html From 93f88bc498ed4d4d44045c083a1a5e74b25c5e13 Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 27 Dec 2024 13:34:32 +0000 Subject: [PATCH 3/4] Styling for pagination --- _includes/posts.html | 25 ++++++++++++++++--------- assets/css/bpd.css | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/_includes/posts.html b/_includes/posts.html index 583964f..f05910b 100644 --- a/_includes/posts.html +++ b/_includes/posts.html @@ -30,21 +30,28 @@

{% if site.paginate %} -
-
    +
- {%- endif %} + + {%- endif %} {%- endif -%} diff --git a/assets/css/bpd.css b/assets/css/bpd.css index b26d4e1..0f1c318 100644 --- a/assets/css/bpd.css +++ b/assets/css/bpd.css @@ -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; +} From c78b4d5c31debcece7e367048a95825f86c8fb7f Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Fri, 27 Dec 2024 17:48:17 +0000 Subject: [PATCH 4/4] Removed home path for testing blog description --- tests/test.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test.py b/tests/test.py index 88bfcab..3c068dc 100644 --- a/tests/test.py +++ b/tests/test.py @@ -106,10 +106,7 @@ def test_mailto_bpdevs(page_url: tuple[Page, str]) -> None: @pytest.mark.parametrize( "url", - ( - "/", - "/blog", - ), + ("/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`"""