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.
This commit is contained in:
@@ -13,6 +13,7 @@ columns:
|
|||||||
fieldsets:
|
fieldsets:
|
||||||
- heading
|
- heading
|
||||||
- text
|
- text
|
||||||
|
- markdown
|
||||||
- image
|
- image
|
||||||
- line
|
- line
|
||||||
- gallery
|
- gallery
|
||||||
@@ -51,6 +52,17 @@ columns:
|
|||||||
label: Zusammenfassung
|
label: Zusammenfassung
|
||||||
type: textarea
|
type: textarea
|
||||||
size: small
|
size: small
|
||||||
|
tags:
|
||||||
|
label: Tags
|
||||||
|
type: multiselect
|
||||||
|
min: 1
|
||||||
|
max: 3
|
||||||
|
options:
|
||||||
|
Spielbericht: Spielbericht
|
||||||
|
Vereinsleben: Vereinsleben
|
||||||
|
Vereinsmeisterschaft: Vereinsmeisterschaft
|
||||||
|
Pressebericht: Pressebericht
|
||||||
|
Turnierbericht: Turnierbericht
|
||||||
author:
|
author:
|
||||||
label: Autor
|
label: Autor
|
||||||
type: users
|
type: users
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<div class="py-16">
|
||||||
|
<h2>Neuigkeiten aus dem Verein</h2>
|
||||||
|
<div class="mx-auto mt-16 grid max-w-2xl grid-cols-1 gap-x-8 gap-y-20 lg:mx-0 lg:max-w-none lg:grid-cols-3">
|
||||||
|
<?php foreach($news as $post): ?>
|
||||||
|
<article class="flex flex-col items-start justify-between">
|
||||||
|
<div class="relative w-full">
|
||||||
|
<img src="<?= $post->image()->url() ?>" alt="" class="w-full h-64 rounded-xl object-cover" />
|
||||||
|
<div class="absolute inset-0 rounded-2xl inset-ring inset-ring-gray-900/10"></div>
|
||||||
|
</div>
|
||||||
|
<div class="flex max-w-xl grow flex-col justify-between">
|
||||||
|
<div class="mt-8 flex items-center gap-x-4 text-xs">
|
||||||
|
<time class="text-gray-500"><?= $post->date()->toDate("d.m.Y") ?></time>
|
||||||
|
<?php foreach($post->tags()->split() as $tag): ?>
|
||||||
|
<a href="<?= page('news')->url(['params' => ['tag' => $tag]]) ?>" class="relative z-10 rounded-full bg-gray-50 px-3 py-1.5 font-medium text-gray-600 hover:bg-gray-100"><?= $tag ?></a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<div class="group relative grow">
|
||||||
|
<h2>
|
||||||
|
<a href="<?= $post->url() ?>">
|
||||||
|
<span class="absolute inset-0"></span>
|
||||||
|
<?= $post->headline() ?>
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
<p><?= $post->summary() ?></p>
|
||||||
|
</div>
|
||||||
|
<?php if ($user = $post->author()->toUser()): ?>
|
||||||
|
<div class="mt-6 flex border-t border-gray-900/5 pt-6">
|
||||||
|
<div class="relative flex items-center gap-x-4">
|
||||||
|
<img src="<?= $user->avatar()->url() ?>" alt="" class="size-10 rounded-full bg-gray-50" />
|
||||||
|
<div class="text-sm/6">
|
||||||
|
<p>
|
||||||
|
<a href="#">
|
||||||
|
<span class="absolute inset-0"></span>
|
||||||
|
<div class="text-xl">
|
||||||
|
<?= $user->username() ?>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p class="text-sm"><?= $user->role()->title() ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -107,16 +107,28 @@
|
|||||||
|
|
||||||
// Funktion zum Aktualisieren der Sichtbarkeit der Pfeile
|
// Funktion zum Aktualisieren der Sichtbarkeit der Pfeile
|
||||||
function updateArrowVisibility() {
|
function updateArrowVisibility() {
|
||||||
scrollLeftBtn.classList.toggle('opacity-50', currentPosition <= 0);
|
// Linker Pfeil nur anzeigen, wenn es vorherige Termine gibt
|
||||||
scrollRightBtn.classList.toggle('opacity-50', currentPosition >= maxPosition);
|
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) {
|
if (totalCards <= cardsToShow) {
|
||||||
scrollLeftBtn.classList.add('hidden');
|
scrollLeftBtn.classList.add('hidden');
|
||||||
scrollRightBtn.classList.add('hidden');
|
scrollRightBtn.classList.add('hidden');
|
||||||
} else {
|
} 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');
|
scrollRightBtn.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +173,8 @@
|
|||||||
// Position aktualisieren
|
// Position aktualisieren
|
||||||
scrollToPosition();
|
scrollToPosition();
|
||||||
|
|
||||||
// Pfeile aktualisieren
|
// Pfeile-Sichtbarkeit aktualisieren
|
||||||
if (totalCards <= cardsToShow) {
|
updateArrowVisibility();
|
||||||
scrollLeftBtn.classList.add('hidden');
|
|
||||||
scrollRightBtn.classList.add('hidden');
|
|
||||||
} else {
|
|
||||||
scrollLeftBtn.classList.remove('hidden');
|
|
||||||
scrollRightBtn.classList.remove('hidden');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
+35
-13
@@ -1,17 +1,33 @@
|
|||||||
<?php snippet('layout', slots: true) ?>
|
<?php snippet('layout', slots: true) ?>
|
||||||
|
|
||||||
<?php foreach($page->children() as $post): ?>
|
<?php
|
||||||
<article class="relative isolate flex flex-col gap-8 lg:flex-row">
|
// Filterfunktionalität implementieren
|
||||||
|
$posts = $page->children()->sortBy('date', 'desc');
|
||||||
|
|
||||||
|
// Nach Kategorie (Tag) filtern
|
||||||
|
if($tag = param('tag')) {
|
||||||
|
$posts = $posts->filterBy('tags', $tag, ',');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php foreach($posts as $post): ?>
|
||||||
|
<article class="relative flex flex-col gap-8 lg:flex-row py-12">
|
||||||
<div class="relative aspect-video sm:aspect-2/1 lg:aspect-square lg:w-64 lg:shrink-0">
|
<div class="relative aspect-video sm:aspect-2/1 lg:aspect-square lg:w-64 lg:shrink-0">
|
||||||
<img src="<?= $post->image()->url() ?>" alt="" class="absolute inset-0 size-full rounded-2xl bg-gray-50 object-cover" />
|
<img src="<?= $post->image()->url() ?>" alt="" class="absolute inset-0 size-full rounded-xl object-cover" />
|
||||||
<div class="absolute inset-0 rounded-2xl ring-1 ring-gray-900/10 ring-inset"></div>
|
<div class="absolute inset-0 rounded-2xl ring-1 ring-gray-900/10 ring-inset"></div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center gap-x-4 text-xs">
|
<div class="flex items-center gap-x-4 text-m justify-between">
|
||||||
<time datetime="2020-03-16" class="text-gray-500"><?= $post->date()->toDate("d.m.Y") ?></time>
|
<div>
|
||||||
<a href="#" class="relative z-10 rounded-full bg-gray-50 px-3 py-1.5 font-medium text-gray-600 hover:bg-gray-100">Marketing</a>
|
<time class="text-gray-500"><?= $post->date()->toDate("d.m.Y") ?></time>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<?php foreach($post->tags()->split() as $tag): ?>
|
||||||
|
<a href="<?= $page->url(['params' => ['tag' => $tag]]) ?>" class="relative z-10 rounded-full bg-gray-50 px-3 py-1.5 font-medium text-gray-600 hover:bg-gray-100"><?= $tag ?></a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="group relative max-w-xl">
|
<div class="group relative">
|
||||||
<h2>
|
<h2>
|
||||||
<a href="<?= $post->url() ?>" class="relative">
|
<a href="<?= $post->url() ?>" class="relative">
|
||||||
<span class="absolute inset-0"></span>
|
<span class="absolute inset-0"></span>
|
||||||
@@ -26,12 +42,10 @@
|
|||||||
<img src="<?= $user->avatar()->url() ?>" alt="" class="size-10 rounded-full bg-gray-50" />
|
<img src="<?= $user->avatar()->url() ?>" alt="" class="size-10 rounded-full bg-gray-50" />
|
||||||
<div class="text-sm/6">
|
<div class="text-sm/6">
|
||||||
<p>
|
<p>
|
||||||
<a href="#">
|
<span class="absolute inset-0"></span>
|
||||||
<span class="absolute inset-0"></span>
|
<div class="text-xl">
|
||||||
<div class="text-xl">
|
<?= $user->username() ?>
|
||||||
<?= $user->username() ?>
|
</div>
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm"><?= $user->role()->title() ?></p>
|
<p class="text-sm"><?= $user->role()->title() ?></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,5 +55,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<?php if(param('tag')): ?>
|
||||||
|
<div class="my-8">
|
||||||
|
<a href="<?= $page->url() ?>" class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-semibold py-2 px-4 rounded">
|
||||||
|
Alle Beiträge anzeigen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php endsnippet() ?>
|
<?php endsnippet() ?>
|
||||||
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
<h1>Hallo Welt!</h1>
|
<h1>Hallo Welt!</h1>
|
||||||
|
|
||||||
<?php snippet('termine-home') ?>
|
<?php snippet('home-news', [
|
||||||
|
'news' => page('news')
|
||||||
|
->children()
|
||||||
|
->limit(3)
|
||||||
|
->sortBy('date', 'desc')
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<?php snippet('home-termine') ?>
|
||||||
|
|
||||||
<?php endsnippet() ?>
|
<?php endsnippet() ?>
|
||||||
+13
-3
@@ -23,12 +23,23 @@
|
|||||||
|
|
||||||
|
|
||||||
<?php snippet('layout', slots: true) ?>
|
<?php snippet('layout', slots: true) ?>
|
||||||
<p><?= $page->date()->toDate("d.m.Y") ?> - <?= $page->subheadline() ?></p>
|
<div class="text-right pb-2">
|
||||||
|
<?php foreach($page->tags()->split() as $tag): ?>
|
||||||
|
<a href="<?= page('news')->url(['params' => ['tag' => $tag]]) ?>" class="relative z-10 rounded-full bg-gray-50 px-3 py-1.5 font-medium text-gray-600 hover:bg-gray-100"><?= $tag ?></a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= $page->date()->toDate("d.m.Y") ?>
|
||||||
|
<?php if ($page->subheadline()->isNotEmpty()): ?>
|
||||||
|
- <?= $page->subheadline() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<h1><?= $page->headline() ?></h1>
|
<h1><?= $page->headline() ?></h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<img src="<?= $page->image()->url() ?>" alt="">
|
<img class="w-full rounded-xl object-cover" src="<?= $page->image()->url() ?>" alt="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="blockpage">
|
<div class="blockpage">
|
||||||
@@ -53,5 +64,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php endsnippet() ?>
|
<?php endsnippet() ?>
|
||||||
Reference in New Issue
Block a user