// src/routes/donauschwaben/persoenlichkeiten/[slug]/+page.server.ts
import { getBySlug } from '$lib/utils/payload'
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'

export const load: PageServerLoad = async ({ params, fetch }) => {
    const person = await getBySlug('persoenlichkeiten', params.slug, {}, fetch)

    if (!person) {
        error(404, 'Person nicht gefunden')
    }

    return {
        person,
        // Pass all locale slugs for the language switcher
        localeSlugs: person.slug
    }
}