From f7f5cdc145bce59562aaaf6893333c78f71afc3f Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Wed, 9 Oct 2024 21:20:27 +0200
Subject: [PATCH] Add blog overview page

---
 config.toml                  |  4 ++++
 content/blog/_index.md       |  1 +
 sass/_menu.scss              |  4 ++--
 templates/blog/overview.html | 37 +++++++++++++++++++++++++++++-------
 templates/menu.html          |  4 ++++
 5 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/config.toml b/config.toml
index 26143fab..4f8ebe88 100644
--- a/config.toml
+++ b/config.toml
@@ -49,6 +49,10 @@ skip_prefixes = [
 #url =
 #alt =
 
+[[extra.main_menu_item]]
+path = "@/blog/_index.md"
+title = "Blog"
+
 [extra.repo.web]
 tree = "https://edugit.org/Teckids/team-pr/teckids.org/-/tree/master/content"
 issues = "https://edugit.org/Teckids/team-pr/teckids.org/-/issues"
diff --git a/content/blog/_index.md b/content/blog/_index.md
index 8d13e421..1a2a54ac 100644
--- a/content/blog/_index.md
+++ b/content/blog/_index.md
@@ -5,5 +5,6 @@ template = "blog/overview.html"
 page_template = "blog/post.html"
 
 sort_by = "date"
+paginate_by = 15
 generate_feeds = true
 +++
diff --git a/sass/_menu.scss b/sass/_menu.scss
index 7b98d020..52c7bef1 100644
--- a/sass/_menu.scss
+++ b/sass/_menu.scss
@@ -62,12 +62,12 @@
 }
 
 @include mixins.desktop {
-    #main-menu > div > .navbar-item > a {
+    #main-menu > div > .navbar-item > a, #main-menu > div > a.navbar-item {
         color: white;
         font-weight: bold;
     }
 
-    #main-menu > div > .navbar-item > a:hover {
+    #main-menu > div > .navbar-item > a:hover, #main-menu > div > a.navbar-item:hover {
         color: teckids.$orange;
     }
 }
diff --git a/templates/blog/overview.html b/templates/blog/overview.html
index f28434e6..3f181f35 100644
--- a/templates/blog/overview.html
+++ b/templates/blog/overview.html
@@ -1,11 +1,34 @@
 {% extends "base.html" %}
 
+{% block rdfa_type %}schema:Blog{% endblock %}
+
 {% block main %}
-    <div class="my-4">
-            <div class="section">
-                <div class="content container">
-                  Foo
-                </div>
-            </div>
-    </div>
+  {% set title = "Teckids-Blog – Seite " ~ paginator.current_index ~ " von " ~ paginator.number_pagers %}
+  {% set posts = paginator.pages %}
+  {% set count = paginator.paginate_by %}
+  {% include "blog/section.html" %}
+
+  {% if paginator.number_pagers > 1 %}
+  <nav class="pagination is-centered section" role="navigation" aria-label="pagination">
+    <a href="{{ paginator.previous }}" class="pagination-previous">Vorherige</a>
+    <a href="{{ paginator.next }}" class="pagination-next">Nächste</a>
+    <ul class="pagination-list">
+      <li><a href="{{ paginator.first }}" class="pagination-link {% if paginator.current_index == 1 %}is-current{% endif %}" aria-label="Seite 1">1</a></li>
+      {% set range_start = paginator.current_index - 3 %}
+      {% if range_start < 2 %}{% set range_start = 2 %}{% endif %}
+      {% set range_end = paginator.current_index + 3 %}
+      {% if range_end > paginator.number_pagers - 1 %}{% set range_end = paginator.number_pagers - 1 %}{% endif %}
+      {% if range_start > 2 %}
+        <li><span class="pagination-ellipsis">&hellip;</span></li>
+      {% endif %}
+      {% for pn in range(start=range_start, end=range_end + 1) %}
+      <li><a href="{{ paginator.base_url ~ pn ~ "/" }}" class="pagination-link {% if pn == paginator.current_index %}is-current{% endif %}" aria-label="Seite {{ pn }}">{{ pn }}</a></li>      
+      {% endfor %}
+      {% if range_end < paginator.number_pagers - 1 %}
+        <li><span class="pagination-ellipsis">&hellip;</span></li>
+      {% endif %}
+      <li><a href="{{ paginator.last }}" class="pagination-link {% if paginator.current_index == paginator.number_pagers %}is-current{% endif %}" aria-label="Seite {{ paginator.number_pagers }}">{{ paginator.number_pagers }}</a></li>
+    </ul>
+  </nav>
+  {% endif %}
 {% endblock %}
diff --git a/templates/menu.html b/templates/menu.html
index fdda3507..592169ba 100644
--- a/templates/menu.html
+++ b/templates/menu.html
@@ -37,6 +37,10 @@
                     {% include "menu/gemeinschaft.html" %}
                 </div>
             </div>
+
+            {% for item in config.extra.main_menu_item %}
+              <a href="{{ get_url(path=item.path) }}" class="navbar-item is-hoverable">{{ item.title }}</a>
+            {% endfor %}
         </div>
     </div>
 </nav>
-- 
GitLab