import { posts, type Post } from '../posts/posts_data';

export interface BlogData {
    summaries: Post[],
    post: Post
}

export async function load({ url, parent }) : Promise<BlogData> {
    const { summaries } = await parent();
    const websiteUrl = url.pathname.split('/');
    const windowUrl = websiteUrl.pop() || websiteUrl.pop(); // Handle trailing /

    return {
        summaries: summaries,
        post: posts.filter((post) => post.url == windowUrl)[0],
    };
}
