Browse Source

split blog index over two pages

Thomas B 1 month ago
parent
commit
29faf33a8c
3 changed files with 28 additions and 2 deletions
  1. 5
    1
      input/blog.md
  2. 16
    0
      input/blog_old.md
  3. 7
    1
      macros.py

+ 5
- 1
input/blog.md View File

@@ -12,5 +12,9 @@ noheader: true
12 12
 To receive my latest updates, you can subscribe to the <a href="rss.xml"><img src="img/rss.png">RSS Feed</a>.
13 13
 
14 14
 <!--%
15
-printBlogMenu()
15
+import datetime
16
+year = int(datetime.date.today().year)
17
+printBlogMenu(str(year - 5), None)
16 18
 %-->
19
+
20
+[Click here](blog_old.html) for older blog posts.

+ 16
- 0
input/blog_old.md View File

@@ -0,0 +1,16 @@
1
+title: Old Blog Posts
2
+parent: none
3
+noheader: true
4
+---
5
+
6
+# Old Blog Archive
7
+
8
+[Click here](blog.html) for the more recent blog posts.
9
+
10
+To receive my latest updates, you can subscribe to the <a href="rss.xml"><img src="img/rss.png">RSS Feed</a>.
11
+
12
+<!--%
13
+import datetime
14
+year = int(datetime.date.today().year)
15
+printBlogMenu(None, str(year - 5 - 1))
16
+%-->

+ 7
- 1
macros.py View File

@@ -170,9 +170,15 @@ def printRecentMenu(count = 5):
170 170
     for p in posts:
171 171
         printMenuItem(p, False, False, False, True, "0", "", False)
172 172
 
173
-def printBlogMenu():
173
+def printBlogMenu(year_min=None, year_max=None):
174 174
     posts = [p for p in pages if "post" in p and p.lang == "en"]
175 175
     posts.sort(key=lambda p: p.get("date", "9999-01-01"), reverse=True)
176
+
177
+    if year_min != None:
178
+        posts = [p for p in posts if int(p.get("date", "9999-01-01")[0:4]) >= int(year_min)]
179
+    if year_max != None:
180
+        posts = [p for p in posts if int(p.get("date", "9999-01-01")[0:4]) <= int(year_max)]
181
+
176 182
     lastyear = "0"
177 183
     for p in posts:
178 184
         lastyear = printMenuItem(p, True, False, False, True, lastyear)

Loading…
Cancel
Save