<script lang="ts">
	import { PostListBloc } from '$lib/post/adapter/presenter/postListBloc';
	import { getContext, setContext } from 'svelte';
	import type { PageProps } from './$types';
	import { PostInfoViewModel } from '$lib/post/adapter/presenter/postInfoViewModel';
	import PostOverallPage from '$lib/post/framework/ui/PostOverallPage.svelte';
	import { Container } from '$lib/container';

	const { data }: PageProps = $props();
	const container = getContext<Container>(Container.name);

	const initialData = data.dehydratedData?.map((post) => PostInfoViewModel.rehydrate(post));
	const postListBloc = container.createPostListBloc(initialData);
	setContext(PostListBloc.name, postListBloc);
</script>

<PostOverallPage />
