Globale Live-Suche, Kontaktkarten-Personensuche, neue Beitragsansicht, Termine mit Seitenleiste, Demo-Inhalte, Plugin-Upload-Fix
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m24s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m26s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m31s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m18s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m24s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m26s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m31s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m18s
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:
parent
9b06e65802
commit
b276e1c6d0
211 changed files with 3580 additions and 1072 deletions
|
|
@ -1,63 +1,142 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, Clock, PenLine } from '@lucide/vue';
|
||||
import { useWindowScroll } from '@vueuse/core';
|
||||
import { ArrowLeft, CalendarDays, Check, Clock, Link2, Mail, PenLine } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import CategoryLabel from '../components/CategoryLabel.vue';
|
||||
import NewsCard from '../components/NewsCard.vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import PageContent from '@/pagebuilder/PageContent.vue';
|
||||
import { formatDate } from '@/lib/format';
|
||||
import { formatDate, formatShortDate } from '@/lib/format';
|
||||
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
post: { type: Object, required: true },
|
||||
related: { type: Object, required: true },
|
||||
editUrl: { type: String, default: null },
|
||||
form: { type: Object, default: null },
|
||||
});
|
||||
|
||||
// Lesefortschritt: Anteil des Artikels, der schon oben aus dem Bild gescrollt ist
|
||||
const article = ref(null);
|
||||
const progress = ref(0);
|
||||
const { y } = useWindowScroll();
|
||||
const updateProgress = () => {
|
||||
const el = article.value;
|
||||
|
||||
if (!el) return;
|
||||
|
||||
const rect = el.getBoundingClientRect();
|
||||
const total = rect.height - window.innerHeight * 0.6;
|
||||
progress.value = Math.min(100, Math.max(0, (-rect.top / Math.max(total, 1)) * 100));
|
||||
};
|
||||
watch(y, updateProgress);
|
||||
|
||||
const copied = ref(false);
|
||||
async function copyLink() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(window.location.href);
|
||||
copied.value = true;
|
||||
setTimeout(() => (copied.value = false), 2000);
|
||||
} catch {
|
||||
window.prompt('Link zum Beitrag:', window.location.href);
|
||||
}
|
||||
}
|
||||
|
||||
const mailLink = () => `mailto:?subject=${encodeURIComponent(props.post.title)}&body=${encodeURIComponent(window.location.href)}`;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :title="post.title">
|
||||
<article class="mx-auto max-w-3xl">
|
||||
<div class="mb-6 flex items-center justify-between gap-4">
|
||||
<Link href="/neuigkeiten" class="inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground">
|
||||
<ArrowLeft class="size-4" /> Alle Neuigkeiten
|
||||
</Link>
|
||||
<Button v-if="editUrl" variant="outline" size="sm" as-child><Link :href="editUrl"><PenLine /> Bearbeiten</Link></Button>
|
||||
<!-- Lesefortschritt -->
|
||||
<div class="fixed inset-x-0 top-0 z-50 h-1 bg-transparent" aria-hidden="true">
|
||||
<div class="h-full bg-brand transition-[width] duration-150" :style="{ width: `${progress}%` }" />
|
||||
</div>
|
||||
|
||||
<div class="mb-4 flex items-center justify-between gap-4">
|
||||
<Link href="/neuigkeiten" class="inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground">
|
||||
<ArrowLeft class="size-4" /> Alle Neuigkeiten
|
||||
</Link>
|
||||
<Button v-if="editUrl" variant="outline" size="sm" as-child><Link :href="editUrl"><PenLine /> Bearbeiten</Link></Button>
|
||||
</div>
|
||||
|
||||
<!-- Kopf: großes Titelbild mit Titel darüber, ohne Bild eine Fläche in der Markenfarbe -->
|
||||
<header class="relative isolate overflow-hidden rounded-xl bg-brand text-white shadow-sm">
|
||||
<img v-if="post.cover_url" :src="post.cover_url" :alt="post.title" class="absolute inset-0 -z-10 size-full object-cover" />
|
||||
<div v-if="post.cover_url" class="absolute inset-0 -z-10 bg-gradient-to-t from-black/85 via-black/45 to-black/5" />
|
||||
<div v-else class="absolute inset-0 -z-10 opacity-20 [background-image:radial-gradient(circle_at_85%_15%,white_0,transparent_45%),radial-gradient(circle_at_10%_110%,white_0,transparent_40%)]" />
|
||||
|
||||
<div class="flex min-h-[260px] flex-col justify-end gap-3 p-6 sm:min-h-[360px] sm:p-10 lg:min-h-[420px]">
|
||||
<span v-if="post.category" class="w-fit rounded-full bg-white/15 px-3 py-1 text-[11px] font-semibold tracking-wider uppercase ring-1 ring-white/30 backdrop-blur">
|
||||
{{ post.category.name }}
|
||||
</span>
|
||||
<h1 class="max-w-4xl text-3xl leading-tight font-semibold tracking-tight text-balance sm:text-4xl lg:text-[44px]">{{ post.title }}</h1>
|
||||
<p v-if="post.teaser" class="max-w-3xl text-base leading-relaxed text-white/85 sm:text-lg">{{ post.teaser }}</p>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-white/80">
|
||||
<span class="inline-flex items-center gap-1.5"><CalendarDays class="size-4" /> {{ formatDate(post.published_at) }}</span>
|
||||
<span class="inline-flex items-center gap-1.5"><Clock class="size-4" /> {{ post.reading_minutes }} Min. Lesezeit</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<header>
|
||||
<CategoryLabel :category="post.category" />
|
||||
<h1 class="mt-2 text-3xl leading-tight font-semibold tracking-tight sm:text-[34px]">{{ post.title }}</h1>
|
||||
<p v-if="post.teaser" class="mt-4 text-lg leading-relaxed text-muted-foreground">{{ post.teaser }}</p>
|
||||
<div class="mt-6 grid gap-6 lg:grid-cols-12">
|
||||
<!-- Inhalt in einer weißen Karte -->
|
||||
<article ref="article" class="min-w-0 rounded-xl border bg-card p-6 shadow-xs sm:p-10 lg:col-span-8">
|
||||
<!-- Am Handy steht die Seitenleiste unten – dort den Autor gleich oben zeigen -->
|
||||
<div v-if="post.author" class="mb-8 flex items-center gap-3 border-b pb-6 lg:hidden">
|
||||
<PersonAvatar :person="post.author" class="size-11" />
|
||||
<div class="min-w-0 text-sm">
|
||||
<Link :href="`/personen/${post.author.id}`" class="font-semibold hover:underline">{{ post.author.name }}</Link>
|
||||
<p v-if="post.author.job_title" class="text-muted-foreground">{{ post.author.job_title }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex flex-wrap items-center gap-x-6 gap-y-3 border-y py-4 text-sm">
|
||||
<Link v-if="post.author" :href="`/personen/${post.author.id}`" class="flex items-center gap-3 hover:underline">
|
||||
<PersonAvatar :person="post.author" class="size-9" />
|
||||
<span>
|
||||
<span class="block font-medium">{{ post.author.name }}</span>
|
||||
<span v-if="post.author.job_title" class="block text-xs text-muted-foreground">{{ post.author.job_title }}</span>
|
||||
<div
|
||||
class="prose prose-neutral max-w-none prose-headings:tracking-tight prose-h2:mt-10 prose-a:text-brand-text prose-blockquote:border-l-brand prose-blockquote:bg-brand-soft/50 prose-blockquote:py-1 prose-blockquote:not-italic prose-img:rounded-lg dark:prose-invert first-of-type:prose-p:text-lg"
|
||||
v-html="post.body_html"
|
||||
/>
|
||||
|
||||
<!-- Eingebundenes Formular (Pagebuilder-Block des Formular-Plugins) -->
|
||||
<PageContent v-if="form" :content="form" class="mt-10" />
|
||||
|
||||
<footer class="mt-10 flex flex-wrap items-center gap-2 border-t pt-6">
|
||||
<span class="mr-2 text-sm text-muted-foreground">Beitrag teilen:</span>
|
||||
<Button variant="outline" size="sm" @click="copyLink">
|
||||
<component :is="copied ? Check : Link2" /> {{ copied ? 'Link kopiert' : 'Link kopieren' }}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" as-child><a :href="mailLink()"><Mail /> Per E-Mail</a></Button>
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
<aside class="grid content-start gap-6 lg:col-span-4">
|
||||
<section v-if="post.author" class="rounded-xl border bg-card p-5 shadow-xs">
|
||||
<h2 class="mb-3 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Geschrieben von</h2>
|
||||
<Link :href="`/personen/${post.author.id}`" class="flex items-center gap-3 rounded-lg p-1 hover:bg-accent/50">
|
||||
<PersonAvatar :person="post.author" class="size-14" />
|
||||
<span class="min-w-0">
|
||||
<span class="block font-semibold">{{ post.author.name }}</span>
|
||||
<span v-if="post.author.job_title" class="block text-[13px] text-muted-foreground">{{ post.author.job_title }}</span>
|
||||
</span>
|
||||
</Link>
|
||||
<span class="text-muted-foreground">{{ formatDate(post.published_at) }}</span>
|
||||
<span class="inline-flex items-center gap-1.5 text-muted-foreground"><Clock class="size-4" /> {{ post.reading_minutes }} Min. Lesezeit</span>
|
||||
</div>
|
||||
</header>
|
||||
</section>
|
||||
|
||||
<img v-if="post.cover_url" :src="post.cover_url" :alt="post.title" class="mt-8 aspect-video w-full rounded-lg object-cover" />
|
||||
|
||||
<div class="prose prose-neutral mt-8 max-w-none prose-headings:tracking-tight prose-img:rounded-lg" v-html="post.body_html" />
|
||||
|
||||
<!-- Eingebundenes Formular (Pagebuilder-Block des Formular-Plugins) -->
|
||||
<PageContent v-if="form" :content="form" class="mt-10" />
|
||||
</article>
|
||||
|
||||
<section v-if="related.data.length" class="mx-auto mt-16 max-w-5xl">
|
||||
<h2 class="mb-4 text-lg font-semibold">Weitere Beiträge</h2>
|
||||
<div class="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<NewsCard v-for="item in related.data" :key="item.id" :post="item" />
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="related.data.length" class="rounded-xl border bg-card p-5 shadow-xs lg:sticky lg:top-20">
|
||||
<h2 class="mb-3 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Weitere Beiträge</h2>
|
||||
<ul class="grid gap-1">
|
||||
<li v-for="item in related.data" :key="item.id">
|
||||
<Link :href="`/neuigkeiten/${item.slug}`" class="group flex gap-3 rounded-lg p-2 hover:bg-accent/50">
|
||||
<img v-if="item.thumb_url" :src="item.thumb_url" alt="" loading="lazy" class="h-16 w-20 shrink-0 rounded-md object-cover" />
|
||||
<span v-else class="grid h-16 w-20 shrink-0 place-items-center rounded-md bg-brand-soft text-brand-text"><CalendarDays class="size-5" /></span>
|
||||
<span class="min-w-0">
|
||||
<span v-if="item.category" class="block text-[10px] font-semibold tracking-wider text-accent2-text uppercase">{{ item.category.name }}</span>
|
||||
<span class="line-clamp-2 text-sm leading-snug font-medium group-hover:underline">{{ item.title }}</span>
|
||||
<span class="block text-xs text-muted-foreground">{{ formatShortDate(item.published_at) }}</span>
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
<Link href="/neuigkeiten" class="mt-3 block border-t pt-3 text-[13px] font-medium text-brand-text hover:underline">Alle Neuigkeiten</Link>
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class NewsController extends Controller
|
|||
->visibleTo(request()->user())
|
||||
->with('category')
|
||||
->whereKeyNot($post->id)
|
||||
->when($post->category_id, fn ($query) => $query->where('category_id', $post->category_id))
|
||||
->orderByRaw('category_id = ? DESC', [$post->category_id ?? 0])
|
||||
->latest('published_at')
|
||||
->limit(3)
|
||||
->limit(5)
|
||||
->get()
|
||||
),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use App\Pagebuilder\Blocks;
|
|||
use App\Pagebuilder\BlockType;
|
||||
use App\Pagebuilder\Field;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
|
@ -24,6 +25,8 @@ class NewsPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(GlobalSearch::class)->add('news', 'Neuigkeiten', 'newspaper', fn (...$args) => app(NewsSearch::class)(...$args), sort: 10);
|
||||
|
||||
$this->app->make(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: ['news.index', 'news.show'], sort: 20);
|
||||
|
||||
$abilities = $this->app->make(Abilities::class);
|
||||
|
|
|
|||
28
plugins-core/news/src/NewsSearch.php
Normal file
28
plugins-core/news/src/NewsSearch.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\News;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Search\GlobalSearch;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
||||
/** Suchquelle für die globale Suche */
|
||||
class NewsSearch
|
||||
{
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, string $search, int $limit): array
|
||||
{
|
||||
$query = NewsPost::query()->published()->visibleTo($user)->with('category');
|
||||
GlobalSearch::whereTerms($query, ['title', 'teaser', 'body'], $search);
|
||||
|
||||
return $query->latest('published_at')->limit($limit)->get()->map(fn (NewsPost $post) => [
|
||||
'title' => $post->title,
|
||||
'url' => route('news.show', $post->slug),
|
||||
'excerpt' => GlobalSearch::excerpt($post->teaser.' '.$post->body_html, $search),
|
||||
'meta' => collect([$post->category?->name, $post->published_at?->translatedFormat('j. F Y')])->filter()->implode(' · '),
|
||||
'image' => $post->coverUrl('thumb'),
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue