Startseite frei gestalten, Neuigkeiten-Block mit Kategorien-Filter (0.26.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m21s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m55s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m25s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 09:38:18 +00:00
parent 6290e09074
commit 2c96fcce1c
151 changed files with 1515 additions and 317 deletions

View file

@ -1,26 +1,75 @@
<script setup>
import { computed } from 'vue';
import { Link } from '@inertiajs/vue3';
import { ChevronRight } from '@lucide/vue';
import { ArrowRight, ChevronRight } from '@lucide/vue';
import CategoryLabel from '../components/CategoryLabel.vue';
import NewsCard from '../components/NewsCard.vue';
import NewsImage from '../components/NewsImage.vue';
import NewsListItem from '../components/NewsListItem.vue';
import { formatShortDate } from '@/lib/format';
defineProps({ block: { type: Object, required: true } });
/**
* Block „Neuigkeiten“: Kacheln, Liste, große Vorschau (untereinander, in breiten
* Bereichen nebeneinander) oder Aufmacher mit Liste. Link „Alle Beiträge“ führt
* zur passend gefilterten Übersicht.
*/
const props = defineProps({ block: { type: Object, required: true } });
const posts = computed(() => props.block.props?.posts ?? []);
const layout = computed(() => props.block.data.layout ?? 'cards');
const boxed = computed(() => ['large', 'featured'].includes(layout.value));
const moreLabel = computed(() => props.block.data.more_label ?? 'Alle anzeigen');
</script>
<template>
<section>
<div v-if="block.data.title" class="mb-3 flex items-center justify-between gap-4">
<h3 class="text-lg font-semibold">{{ block.data.title }}</h3>
<Link v-if="block.props?.more_url" :href="block.props.more_url" class="inline-flex items-center gap-0.5 text-[13px] font-medium text-brand-text hover:underline">
Alle anzeigen <ChevronRight class="size-3.5" />
<section :class="boxed ? '@container rounded-lg border bg-card p-5' : ''">
<div v-if="block.data.title || (!boxed && moreLabel)" class="mb-4 flex items-center justify-between gap-4">
<h3 v-if="block.data.title" class="text-lg font-semibold">{{ block.data.title }}</h3>
<Link v-if="!boxed && moreLabel && block.props?.more_url" :href="block.props.more_url" class="inline-flex shrink-0 items-center gap-0.5 text-[13px] font-medium text-brand-text hover:underline">
{{ moreLabel }} <ChevronRight class="size-3.5" />
</Link>
</div>
<div v-if="block.data.layout === 'list'" class="divide-y rounded-lg border bg-card px-4">
<NewsListItem v-for="post in block.props?.posts ?? []" :key="post.id" :post="post" />
<!-- Große Vorschau -->
<div v-if="layout === 'large'" class="grid gap-6 @3xl:grid-cols-3">
<Link v-for="post in posts" :key="post.id" :href="`/neuigkeiten/${post.slug}`" class="group grid content-start gap-3">
<NewsImage :src="post.cover_url ?? post.thumb_url" :alt="post.title" class="rounded-md" />
<div class="min-w-0">
<CategoryLabel :category="post.category" />
<h4 class="mt-1 line-clamp-2 text-base leading-snug font-semibold group-hover:underline">{{ post.title }}</h4>
<p v-if="post.teaser" class="mt-1 line-clamp-2 text-[13px] text-muted-foreground">{{ post.teaser }}</p>
<p class="mt-1.5 text-xs text-muted-foreground">{{ formatShortDate(post.published_at) }}</p>
</div>
</Link>
</div>
<!-- Aufmacher und Liste -->
<div v-else-if="layout === 'featured'" class="grid gap-4">
<Link v-if="posts[0]" :href="`/neuigkeiten/${posts[0].slug}`" class="group grid content-start gap-3">
<NewsImage :src="posts[0].cover_url ?? posts[0].thumb_url" :alt="posts[0].title" class="rounded-md" />
<div>
<CategoryLabel :category="posts[0].category" />
<h4 class="mt-1 line-clamp-2 text-lg leading-snug font-semibold group-hover:underline">{{ posts[0].title }}</h4>
<p v-if="posts[0].teaser" class="mt-1 line-clamp-3 text-sm text-muted-foreground">{{ posts[0].teaser }}</p>
</div>
</Link>
<div v-if="posts.length > 1" class="divide-y border-t">
<NewsListItem v-for="post in posts.slice(1)" :key="post.id" :post="post" />
</div>
</div>
<div v-else-if="layout === 'list'" class="divide-y rounded-lg border bg-card px-4">
<NewsListItem v-for="post in posts" :key="post.id" :post="post" />
</div>
<div v-else class="grid gap-5 @xl:grid-cols-2 @4xl:grid-cols-3">
<NewsCard v-for="post in block.props?.posts ?? []" :key="post.id" :post="post" />
<NewsCard v-for="post in posts" :key="post.id" :post="post" />
</div>
<p v-if="!(block.props?.posts ?? []).length" class="text-sm text-muted-foreground">Keine Beiträge.</p>
<p v-if="!posts.length" class="text-sm text-muted-foreground">Keine Beiträge.</p>
<Link v-if="boxed && moreLabel && block.props?.more_url" :href="block.props.more_url" class="mt-5 inline-flex items-center gap-1.5 text-sm font-medium text-brand-text hover:underline">
{{ moreLabel }} <ArrowRight class="size-4" />
</Link>
</section>
</template>

View file

@ -11,6 +11,7 @@ defineProps({
posts: { type: Object, required: true },
categories: { type: Array, required: true },
activeCategory: { type: String, default: null },
filter: { type: String, default: null },
canWrite: { type: Boolean, default: false },
});
</script>
@ -27,7 +28,7 @@ defineProps({
<Link
href="/neuigkeiten"
class="rounded-pill border px-3.5 py-1.5 text-[13px] font-medium transition-colors"
:class="!activeCategory ? 'border-brand bg-brand text-brand-foreground' : 'bg-card hover:bg-accent'"
:class="!activeCategory && !filter ? 'border-brand bg-brand text-brand-foreground' : 'bg-card hover:bg-accent'"
preserve-scroll
>
Alle
@ -44,6 +45,11 @@ defineProps({
</Link>
</nav>
<p v-if="filter" class="-mt-3 mb-5 flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground">
<span class="rounded-pill border border-brand bg-brand-soft px-3 py-1 font-medium text-brand-soft-foreground">{{ filter }}</span>
<Link href="/neuigkeiten" class="hover:text-foreground hover:underline">Filter entfernen</Link>
</p>
<div v-if="posts.data.length" class="grid gap-5 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4">
<NewsCard v-for="post in posts.data" :key="post.id" :post="post" />
</div>