Mirror of the sourcecode for my blog, original repo: https://github.com/NobbZ/blog-nobbz-dev
at code-meta 588 B view raw
1// SPDX-FileCopyrightText: 2025 Norbert Melzer 2// SPDX-FileContributor: Norbert Melzer 3// 4// SPDX-License-Identifier: MIT 5 6import { getCollection, type CollectionEntry } from "astro:content"; 7 8export type Author = CollectionEntry<"authors">; 9 10export type WithPosts<T extends Author> = T & { 11 posts: CollectionEntry<"blog">[]; 12}; 13 14export const withPosts = async <T extends Author>( 15 author: T, 16): Promise<WithPosts<T>> => { 17 const posts = await getCollection( 18 "blog", 19 ({ data: { author: postAuthor } }) => author.slug == postAuthor.slug, 20 ); 21 22 return { ...author, posts }; 23};