---
import {createGetStaticPaths} from "astro-i18n";
import { getCollection, CollectionEntry } from "astro:content";
import PageLayout from "../../layouts/PageLayout.astro";
import PublicPreview from "@components/3d/PublicPreview.svelte";
import { Image } from "astro:assets";

export const getStaticPaths = createGetStaticPaths(async () => {
    const pages = await getCollection("publics");

    return pages.map((entry) => ({
        props: {
            schem: entry,
        },
        params: {
            schem: entry.id,
        },
    }));
});

const { schem }: { schem: CollectionEntry<"publics">} = Astro.props;
---

<PageLayout title={schem.data.name}>
    <h1 class="text-5xl font-bold w-fit" transition:name={schem.data.name + "-title"}>{schem.data.name}</h1>
    <PublicPreview client:idle file={schem.id}>
        <Image transition:name={schem.data.name + "-img"} src={schem.data.image} alt={schem.data.name}></Image>
    </PublicPreview>
    <p transition:name={schem.data.name + "-desc"}>{schem.data.description}</p>
    <p>
        Erbauer: {schem.data.creator.join(", ")}
    </p>
</PageLayout>