Skip to content

Commit 08a11ba

Browse files
committed
add pagination
1 parent 6847b61 commit 08a11ba

5 files changed

Lines changed: 28 additions & 7 deletions

File tree

‎_layouts/_includes/header.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h1 class="site-title">
44
<a class="logo-text" href="/index.html"><img src="{{ '/assets/images/black_python_devs_logo-horizontal-white.png' }}" alt="Black Python Devs" /></a>
55
</h1>
6-
<nav class="site-navigation" aria-label="Main navigation">
6+
<nav class="site-navigation" aria-label="Main navigation" style="padding-right: 2em">
77
<div class="site-navigation-wrap">
88
<ul class="menu" role="menu">
99
{% for item in navigation %} {% set current = nil %} {% set nav_lang = nil %} {% if url == item.url %} {% set current = 'nav-current' %} {% endif %} {% if lang != 'en' %} {% set nav_lang = lang %} {% endif %}

‎_layouts/blog-list.html‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@ <h2><a href="{{ page }}.html">
1717
</article>
1818
{% endfor %}
1919
</section>
20-
{% endblock %}
20+
<section>
21+
<div role="group">
22+
<h4>Pages:</h4>
23+
<div>
24+
{% for page in range(1, num_of_pages + 1) %}
25+
<a role="button" {% if page == archive_index %} disabled {% endif %} href="/blog/blog{{page}}.html">{{ page }}</a>
26+
{% endfor %}
27+
</div>
28+
</div>
29+
</section>
30+
{%endblock %}

‎app.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import itertools
12
import datetime
23
import json
34
import pathlib
@@ -86,3 +87,13 @@ class Blog(Blog):
8687
routes = ["./blog"]
8788
has_archive = True
8889
archive_template = "blog-list.html"
90+
items_per_page = 10
91+
92+
93+
if __name__ == "__main__":
94+
blog = app.route_list["blog"]
95+
posts = list(blog)
96+
batched_posts = list(itertools.batched(posts, 10))
97+
print(vars(list(blog.archives)[1]))
98+
print(f"num of posts: {len(posts)}")
99+
print(len(batched_posts))

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "blackpythondevs-site"
33
version = "0.1.0"
44
description = "Black Python Devs community website"
5-
dependencies = ["render-engine[cli]==2025.6.1b2", "pyyaml"]
5+
dependencies = ["render-engine[cli]>=2025.7.1a1", "pyyaml"]
66

77
[project.optional-dependencies]
88
dev = [

‎uv.lock‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)