From 07814712d7fdde605af2e6a0c063b2e9a953a936 Mon Sep 17 00:00:00 2001 From: Tobias Feigel Date: Sun, 13 Jul 2025 12:58:21 +0200 Subject: [PATCH] feat: extend news section with tag filtering, improved layout, and homepage integration Added tag filtering functionality to the blog and news sections, allowing users to filter posts by categories. Enhanced layout with improved tag display, author details, and responsive styling. Integrated the latest news preview into the homepage template. Adjusted visibility logic for navigation arrows in event carousel and refined related PHP snippets for better clarity and reusability. --- site/blueprints/pages/news.yml | 12 +++++ site/snippets/home-news.php | 48 +++++++++++++++++++ .../{termine-home.php => home-termine.php} | 30 +++++++----- site/templates/blog.php | 48 ++++++++++++++----- site/templates/home.php | 9 +++- site/templates/news.php | 16 +++++-- 6 files changed, 134 insertions(+), 29 deletions(-) create mode 100644 site/snippets/home-news.php rename site/snippets/{termine-home.php => home-termine.php} (94%) diff --git a/site/blueprints/pages/news.yml b/site/blueprints/pages/news.yml index 7e6168b..2c2ef20 100644 --- a/site/blueprints/pages/news.yml +++ b/site/blueprints/pages/news.yml @@ -13,6 +13,7 @@ columns: fieldsets: - heading - text + - markdown - image - line - gallery @@ -51,6 +52,17 @@ columns: label: Zusammenfassung type: textarea size: small + tags: + label: Tags + type: multiselect + min: 1 + max: 3 + options: + Spielbericht: Spielbericht + Vereinsleben: Vereinsleben + Vereinsmeisterschaft: Vereinsmeisterschaft + Pressebericht: Pressebericht + Turnierbericht: Turnierbericht author: label: Autor type: users diff --git a/site/snippets/home-news.php b/site/snippets/home-news.php new file mode 100644 index 0000000..66256e4 --- /dev/null +++ b/site/snippets/home-news.php @@ -0,0 +1,48 @@ +
+

Neuigkeiten aus dem Verein

+
+ + + +
+
\ No newline at end of file diff --git a/site/snippets/termine-home.php b/site/snippets/home-termine.php similarity index 94% rename from site/snippets/termine-home.php rename to site/snippets/home-termine.php index 66dcb1c..bb92f9c 100644 --- a/site/snippets/termine-home.php +++ b/site/snippets/home-termine.php @@ -107,16 +107,28 @@ // Funktion zum Aktualisieren der Sichtbarkeit der Pfeile function updateArrowVisibility() { - scrollLeftBtn.classList.toggle('opacity-50', currentPosition <= 0); - scrollRightBtn.classList.toggle('opacity-50', currentPosition >= maxPosition); + // Linker Pfeil nur anzeigen, wenn es vorherige Termine gibt + if (currentPosition <= 0) { + scrollLeftBtn.classList.add('hidden'); + } else { + scrollLeftBtn.classList.remove('hidden'); + } + + // Rechter Pfeil nur anzeigen, wenn es weitere Termine gibt + if (currentPosition >= maxPosition) { + scrollRightBtn.classList.add('hidden'); + } else { + scrollRightBtn.classList.remove('hidden'); + } } - // Initialisierung - verstecke die Pfeile wenn weniger als cardsToShow+1 Karten vorhanden sind + // Initialisierung - zeige die Pfeile nur, wenn es genug Karten gibt if (totalCards <= cardsToShow) { scrollLeftBtn.classList.add('hidden'); scrollRightBtn.classList.add('hidden'); } else { - scrollLeftBtn.classList.remove('hidden'); + // Am Anfang ist der linke Pfeil ausgeblendet, da wir bei Position 0 sind + scrollLeftBtn.classList.add('hidden'); scrollRightBtn.classList.remove('hidden'); } @@ -161,14 +173,8 @@ // Position aktualisieren scrollToPosition(); - // Pfeile aktualisieren - if (totalCards <= cardsToShow) { - scrollLeftBtn.classList.add('hidden'); - scrollRightBtn.classList.add('hidden'); - } else { - scrollLeftBtn.classList.remove('hidden'); - scrollRightBtn.classList.remove('hidden'); - } + // Pfeile-Sichtbarkeit aktualisieren + updateArrowVisibility(); }); }); diff --git a/site/templates/blog.php b/site/templates/blog.php index a31c0fd..574b11b 100644 --- a/site/templates/blog.php +++ b/site/templates/blog.php @@ -1,17 +1,33 @@ - children() as $post): ?> -
+ children()->sortBy('date', 'desc'); + + // Nach Kategorie (Tag) filtern + if($tag = param('tag')) { + $posts = $posts->filterBy('tags', $tag, ','); + } + ?> + + + + + + + \ No newline at end of file diff --git a/site/templates/home.php b/site/templates/home.php index e5a8214..d7f2791 100644 --- a/site/templates/home.php +++ b/site/templates/home.php @@ -2,6 +2,13 @@

Hallo Welt!

- + page('news') + ->children() + ->limit(3) + ->sortBy('date', 'desc') + ]) ?> + + \ No newline at end of file diff --git a/site/templates/news.php b/site/templates/news.php index f2c4d05..3026bb3 100644 --- a/site/templates/news.php +++ b/site/templates/news.php @@ -23,12 +23,23 @@ -

date()->toDate("d.m.Y") ?> - subheadline() ?>

+
+ tags()->split() as $tag): ?> + + +
+ +

+ date()->toDate("d.m.Y") ?> + subheadline()->isNotEmpty()): ?> + - subheadline() ?> + +

headline() ?>

- +
@@ -53,5 +64,4 @@
- \ No newline at end of file