From 6603c5ada8c3b68fc98f43e2a6a23b65492bbb69 Mon Sep 17 00:00:00 2001
From: magicfelix <felix@felix-zauberer.de>
Date: Wed, 2 Oct 2024 19:59:37 +0200
Subject: [PATCH] Show related blog posts on pages

---
 templates/pages/content.html       |  2 ++
 templates/pages/raw.html           |  2 ++
 templates/pages/related_posts.html | 16 ++++++++++++++++
 3 files changed, 20 insertions(+)
 create mode 100644 templates/pages/related_posts.html

diff --git a/templates/pages/content.html b/templates/pages/content.html
index 0e4ef051..1bfe16b7 100644
--- a/templates/pages/content.html
+++ b/templates/pages/content.html
@@ -17,4 +17,6 @@
       {% endblock content %}
     </div>
   </section>
+  {% set related_taxonomy="aspekte" %}
+  {% include "pages/related_posts.html" %}
 {% endblock %}
diff --git a/templates/pages/raw.html b/templates/pages/raw.html
index e2d9395c..a9aacbd3 100644
--- a/templates/pages/raw.html
+++ b/templates/pages/raw.html
@@ -2,4 +2,6 @@
 
 {% block main %}
   {{ page.content | safe }}
+  {% set related_taxonomy="produkte" %}
+  {% include "pages/related_posts.html" %}
 {% endblock %}
diff --git a/templates/pages/related_posts.html b/templates/pages/related_posts.html
new file mode 100644
index 00000000..514ffeb4
--- /dev/null
+++ b/templates/pages/related_posts.html
@@ -0,0 +1,16 @@
+{% set blog_section = get_section(path="blog/_index.md") %}
+<section class="section" resource="{{ blog_section.permalink }}" typeof="schema:Blog">
+  <meta property="schema:publisher" href="https://teckids.org/" />
+  <div class="container">
+    <h2 class="title is-2">{{ title | default(value="Aus dem Teckids-Blog") }}</h2>
+    <div class="columns is-multiline is-same-height mt-4">
+      {% for post in blog_section.pages %}
+        {% if related_taxonomy in post.taxonomies and page.title in post.taxonomies[related_taxonomy] %}
+          <div class="column is-one-third">
+            {% include "blog/card.html" %}
+          </div>
+	{% else %}{% continue %}{% endif %}
+      {% endfor %}
+    </div>
+  </div>
+</section>
-- 
GitLab