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>
93 lines
5.5 KiB
Vue
93 lines
5.5 KiB
Vue
<script setup>
|
|
import { computed, ref, watch } from 'vue';
|
|
import { Link, router } from '@inertiajs/vue3';
|
|
import { useDebounceFn } from '@vueuse/core';
|
|
import { Search, SearchX } from '@lucide/vue';
|
|
import AppIcon from '@/components/AppIcon.vue';
|
|
import EmptyState from '@/components/EmptyState.vue';
|
|
import FileIcon from '@/components/FileIcon.vue';
|
|
import PageHeader from '@/components/PageHeader.vue';
|
|
import AppLayout from '@/layouts/AppLayout.vue';
|
|
import { highlight } from '@/lib/highlight';
|
|
|
|
const props = defineProps({
|
|
query: { type: String, default: '' },
|
|
groups: { type: Array, required: true },
|
|
minLength: { type: Number, default: 2 },
|
|
});
|
|
|
|
const search = ref(props.query);
|
|
const total = computed(() => props.groups.reduce((sum, g) => sum + g.items.length, 0));
|
|
|
|
watch(
|
|
search,
|
|
useDebounceFn((value) => router.get('/suche', value.trim() ? { q: value.trim() } : {}, { preserveState: true, preserveScroll: true, replace: true }), 300),
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<AppLayout title="Suche">
|
|
<PageHeader title="Suche">
|
|
<template #description>
|
|
<template v-if="query.length >= minLength">{{ total ? `${total} Treffer für „${query}“` : `Keine Treffer für „${query}“` }}</template>
|
|
<template v-else>Neuigkeiten, Termine, Seiten, Downloads und Dokumente durchsuchen</template>
|
|
</template>
|
|
</PageHeader>
|
|
|
|
<div class="grid gap-6 lg:grid-cols-12">
|
|
<div class="grid content-start gap-6 lg:col-span-9">
|
|
<label class="relative block">
|
|
<span class="sr-only">Suchbegriff</span>
|
|
<Search class="pointer-events-none absolute top-1/2 left-4 size-5 -translate-y-1/2 text-muted-foreground" />
|
|
<input
|
|
v-model="search"
|
|
type="search"
|
|
autofocus
|
|
placeholder="Wonach suchen Sie?"
|
|
class="h-12 w-full rounded-lg border border-input bg-card pr-4 pl-12 text-base shadow-xs placeholder:text-muted-foreground focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none"
|
|
/>
|
|
</label>
|
|
|
|
<section v-for="group in groups" :id="`treffer-${group.key}`" :key="group.key" class="overflow-hidden rounded-lg border bg-card">
|
|
<header class="flex items-center gap-2.5 border-b px-5 py-3">
|
|
<span class="grid size-8 place-items-center rounded-md bg-brand-soft text-brand-text"><AppIcon :name="group.icon" class="size-4" /></span>
|
|
<h2 class="text-base font-semibold">{{ group.label }}</h2>
|
|
<span class="ml-auto text-xs text-muted-foreground">{{ group.items.length === 20 ? '20+' : group.items.length }} Treffer</span>
|
|
</header>
|
|
<ul class="divide-y">
|
|
<li v-for="item in group.items" :key="item.url">
|
|
<component :is="item.external ? 'a' : Link" :href="item.url" class="group flex items-start gap-4 px-5 py-3.5 transition-colors hover:bg-accent/50">
|
|
<img v-if="item.image" :src="item.image" alt="" loading="lazy" class="hidden h-14 w-20 shrink-0 rounded-md object-cover sm:block" />
|
|
<FileIcon v-else-if="item.file" :extension="item.file" class="shrink-0" />
|
|
<div class="min-w-0 flex-1">
|
|
<h3 class="text-[15px] font-semibold group-hover:underline" v-html="highlight(item.title, query)" />
|
|
<p v-if="item.meta" class="mt-0.5 text-xs text-muted-foreground">{{ item.meta }}</p>
|
|
<p v-if="item.excerpt" class="mt-1 line-clamp-2 text-[13px] text-muted-foreground" v-html="highlight(item.excerpt, query)" />
|
|
</div>
|
|
</component>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<div v-if="query.length >= minLength && !groups.length" class="rounded-lg border bg-card">
|
|
<EmptyState :icon="SearchX" title="Nichts gefunden" text="Andere Schreibweise oder weniger Begriffe versuchen. Personen finden Sie im Personenverzeichnis." />
|
|
</div>
|
|
</div>
|
|
|
|
<aside v-if="groups.length > 1" class="hidden lg:col-span-3 lg:block">
|
|
<nav class="sticky top-20 rounded-lg border bg-card p-4">
|
|
<h2 class="mb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Bereiche</h2>
|
|
<ul class="grid gap-0.5 text-sm">
|
|
<li v-for="group in groups" :key="group.key">
|
|
<a :href="`#treffer-${group.key}`" class="flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-accent">
|
|
<AppIcon :name="group.icon" class="size-4 text-muted-foreground" /> {{ group.label }}
|
|
<span class="ml-auto text-xs text-muted-foreground tabular-nums">{{ group.items.length }}</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
<Link :href="query ? `/personen?q=${encodeURIComponent(query)}` : '/personen'" class="mt-3 block border-t pt-3 text-[13px] text-brand-text hover:underline">„{{ query }}“ im Personenverzeichnis suchen</Link>
|
|
</nav>
|
|
</aside>
|
|
</div>
|
|
</AppLayout>
|
|
</template>
|