import type { Post } from '$lib/utils/index.js';

export const load = async ({ fetch, params }) => {
	const { category } = params;
	const response = await fetch(`/api/rants`);
	const allPosts: Post[] = await response.json();

	const posts = allPosts.filter((post) => post.meta.categories?.includes(category));

	return {
		category,
		posts
	};
};
