import { getBySlug } from '$lib/utils/payload'
import { error } from '@sveltejs/kit'
import type { PageLoad } from './$types'

export const load: PageLoad = async ({ fetch, params }) => {
    const post = await getBySlug('neuigkeiten', params.slug, {
        where: { _status: { equals: 'published' } },
        depth: 1,
    }, fetch)

    if (!post) throw error(404)

    return { post }
}