From a4e35942fee745e64db5d0099ba2582e0fb4417e Mon Sep 17 00:00:00 2001
From: Dennis Fink
Date: Thu, 18 Jun 2026 17:57:51 +0200
Subject: Build the first usable version of the blog
This adds the Lektor project structure, models, templates, styling,
feeds, categories, tags, archives, custom Markdown heading handling, and
the initial content needed to make the blog usable.
---
templates/macros/blog.html | 100 ++++++++++++++++++
templates/macros/pagination.html | 221 +++++++++++++++++++++++++++++++++++++++
2 files changed, 321 insertions(+)
create mode 100644 templates/macros/blog.html
create mode 100644 templates/macros/pagination.html
(limited to 'templates/macros')
diff --git a/templates/macros/blog.html b/templates/macros/blog.html
new file mode 100644
index 0000000..b4caafe
--- /dev/null
+++ b/templates/macros/blog.html
@@ -0,0 +1,100 @@
+{% from "macros/pagination.html" import render_pagination %}
+
+{% macro render_toc(toc, maxdepth=2) %}
+
+{% endmacro %}
+
+{% macro render_blog_post(post, show_toc=True) %}
+
+
+
+
+
+ {% if post.publication_date %}
+
+ {% else %}
+
+
- ⚠
+ -
+ Missing publication date
+
+
+ {% endif %}
+ {% if post.updated_date and post.publication_date and (post.updated_date > post.publication_date) %}
+
+
- Last updated:
+ -
+
+
+
+ {% endif %}
+ {% if post.category %}
+
+
- Category:
+
-
+ {% set category = site.get('/categories/'+post.category) %}
+ {{ category.name }}
+
+
+ {% endif %}
+
+
+ {% if show_toc and post.render_toc %}
+ {% set toc = post.body.toc|default([]) %}
+ {{ render_toc(toc) }}
+ {% endif %}
+
+ {{ post.body }}
+ {% if post.tags %}
+
+ {% endif %}
+
+{% endmacro %}
+
+{% macro render_blog_index(pagination) %}
+ {% for post in pagination.items %}
+ {{ render_blog_post(post, False) }}
+ {% if not loop.last %}
+
+ {% endif %}
+ {% endfor %}
+ {% if pagination.pages > 1 %}
+
+ {% endif %}
+{% endmacro %}
diff --git a/templates/macros/pagination.html b/templates/macros/pagination.html
new file mode 100644
index 0000000..adb1b5c
--- /dev/null
+++ b/templates/macros/pagination.html
@@ -0,0 +1,221 @@
+{% macro render_pagination(pagination, pagination_window=2) %}
+ {% set current = pagination.page %}
+ {% set total = pagination.pages %}
+ {% set window_start = [current - pagination_window, 1] | max %}
+ {% set window_end = [current + pagination_window, total] | min %}
+
+{% endmacro %}
+
+{% macro render_year_archive_navigation(
+ current_year_page,
+ archive_window=2
+ ) %}
+ {% set current_year = current_year_page.year %}
+ {% set first_year_page = current_year_page.first_year_page %}
+ {% set last_year_page = current_year_page.last_year_page %}
+ {% set previous_year_page = current_year_page.previous_year_page %}
+ {% set next_year_page = current_year_page.next_year_page %}
+ {% set first_year = first_year_page.year %}
+ {% set last_year = last_year_page.year %}
+ {% set window_start = [current_year - archive_window, first_year] | max %}
+ {% set window_end = [current_year + archive_window, last_year] | min %}
+
+{% endmacro %}
+
+{% macro render_month_archive_navigation(
+ current_month_page,
+ archive_window=2
+ ) %}
+ {% set year_pages = index_pages('year') | sort(attribute='year') %}
+ {% set ns = namespace(
+ month_pages=[],
+ current_position=none
+ ) %}
+ {% for year_page in year_pages %}
+ {% set ns.month_pages = ns.month_pages + (year_page.subindexes | sort(attribute='month')) %}
+ {% endfor %}
+ {% for month_page in ns.month_pages %}
+ {% if month_page.year == current_month_page.year
+ and month_page.month == current_month_page.month %}
+ {% set ns.current_position = loop.index0 %}
+ {% endif %}
+ {% endfor %}
+ {% set total = ns.month_pages | length %}
+ {% set current_position = ns.current_position %}
+ {% set window_start = [current_position - archive_window, 0] | max %}
+ {% set window_end = [current_position + archive_window, total - 1] | min %}
+ {% set first_month_page = ns.month_pages[0] %}
+ {% set last_month_page = ns.month_pages[total - 1] %}
+ {% set previous_month_page = none %}
+ {% set next_month_page = none %}
+ {% if current_position > 0 %}
+ {% set previous_month_page = ns.month_pages[current_position - 1] %}
+ {% endif %}
+ {% if current_position < total - 1 %}
+ {% set next_month_page = ns.month_pages[current_position + 1] %}
+ {% endif %}
+
+{% endmacro %}
--
cgit v1.3.1