Herzen und Kommentare schon in der Vorschau (0.44.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m4s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m25s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m3s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m26s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 9m49s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m1s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m41s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 45s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s

- NewsPost::withStats: Herzen (Anzahl, eigenes) und Kommentare (Anzahl) für
  alle Vorschau-Abfragen: Übersicht, Widgets, Slider, Block, Profil, „Weitere Beiträge“, API
- NewsPostResource: „comments“ (null bei ausgeschalteten Kommentaren)
- NewsStats.vue in Karte, Listeneintrag, Block-Layouts, Slider und Seitenleiste

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 20:44:37 +00:00
parent 60dd200300
commit 21307fc953
145 changed files with 471 additions and 358 deletions

View file

@ -1,6 +1,7 @@
<script setup>
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { Link } from '@inertiajs/vue3';
import NewsStats from './NewsStats.vue';
import { ArrowRight, ChevronLeft, ChevronRight, Pause, Play } from '@lucide/vue';
const props = defineProps({
@ -66,6 +67,7 @@ onBeforeUnmount(stop);
</span>
<h2 class="text-2xl leading-tight font-semibold tracking-tight sm:text-[32px]">{{ current.title }}</h2>
<p v-if="current.teaser" class="mt-3 line-clamp-3 hidden text-[15px] text-white/85 sm:block">{{ current.teaser }}</p>
<NewsStats v-if="current.likes || current.comments" :post="current" light class="mt-3" />
<Link
:href="`/neuigkeiten/${current.slug}`"
class="mt-5 inline-flex w-fit items-center gap-2 rounded-md bg-brand px-4 py-2.5 text-sm font-medium text-brand-foreground transition-colors hover:bg-brand-700"

View file

@ -1,8 +1,8 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { Heart } from '@lucide/vue';
import CategoryLabel from './CategoryLabel.vue';
import NewsImage from './NewsImage.vue';
import NewsStats from './NewsStats.vue';
import { formatShortDate } from '@/lib/format';
defineProps({
@ -19,7 +19,7 @@ defineProps({
<p v-if="post.teaser" class="mt-1.5 line-clamp-2 text-[13px] text-muted-foreground">{{ post.teaser }}</p>
<p class="mt-auto flex items-center gap-1 pt-3 text-xs text-muted-foreground">
{{ formatShortDate(post.published_at) }} · {{ post.reading_minutes }} Min.
<span v-if="post.likes" class="ml-auto inline-flex items-center gap-1 tabular-nums" :title="`${post.likes} ${post.likes === 1 ? 'Herz' : 'Herzen'}`"><Heart class="size-3.5" :class="post.liked ? 'fill-current text-brand-text' : ''" /> {{ post.likes }}</span>
<NewsStats :post="post" class="ml-auto" />
</p>
</div>
</Link>

View file

@ -2,6 +2,7 @@
import { Link } from '@inertiajs/vue3';
import CategoryLabel from './CategoryLabel.vue';
import NewsImage from './NewsImage.vue';
import NewsStats from './NewsStats.vue';
import { formatRelative } from '@/lib/format';
defineProps({
@ -12,10 +13,13 @@ defineProps({
<template>
<Link :href="`/neuigkeiten/${post.slug}`" class="group flex gap-4 py-3">
<NewsImage :src="post.thumb_url" :alt="post.title" class="w-28 shrink-0 rounded-md sm:w-32" />
<div class="min-w-0">
<div class="min-w-0 flex-1">
<CategoryLabel :category="post.category" />
<h3 class="mt-0.5 line-clamp-2 text-sm leading-snug font-semibold group-hover:underline">{{ post.title }}</h3>
<p class="mt-1 text-xs text-muted-foreground">{{ formatRelative(post.published_at) }}</p>
<p class="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground">
{{ formatRelative(post.published_at) }}
<NewsStats :post="post" />
</p>
</div>
</Link>
</template>

View file

@ -0,0 +1,42 @@
<script setup>
import { Heart, MessageCircle } from '@lucide/vue';
import { computed } from 'vue';
/**
* Herzen und Kommentare eines Beitrags – schon in der Vorschau sichtbar.
* Kommentare fehlen, wenn sie für den Beitrag ausgeschaltet sind (comments = null).
*/
const props = defineProps({
post: { type: Object, required: true },
light: { type: Boolean, default: false },
});
const hasLikes = computed(() => typeof props.post.likes === 'number');
const hasComments = computed(() => typeof props.post.comments === 'number');
const label = computed(() =>
[
hasLikes.value ? `${props.post.likes} ${props.post.likes === 1 ? 'Herz' : 'Herzen'}` : null,
hasComments.value ? `${props.post.comments} ${props.post.comments === 1 ? 'Kommentar' : 'Kommentare'}` : null,
]
.filter(Boolean)
.join(', '),
);
</script>
<template>
<span
v-if="hasLikes || hasComments"
class="inline-flex items-center gap-3 text-xs tabular-nums"
:class="light ? 'text-white/85' : 'text-muted-foreground'"
role="img"
:aria-label="label"
:title="label"
>
<span v-if="hasLikes" class="inline-flex items-center gap-1">
<Heart class="size-3.5" :class="post.liked ? (light ? 'fill-current' : 'fill-current text-brand-text') : ''" aria-hidden="true" />{{ post.likes }}
</span>
<span v-if="hasComments" class="inline-flex items-center gap-1">
<MessageCircle class="size-3.5" aria-hidden="true" />{{ post.comments }}
</span>
</span>
</template>