From 4b30d58db6db2f2514a0ec377aa3bbb1e0a8a500 Mon Sep 17 00:00:00 2001 From: tobias Date: Tue, 21 May 2024 12:04:23 +0200 Subject: [PATCH] Type posts --- astro/src/components/{Post.astro => PostEntry.astro} | 5 +++++ astro/src/components/Posts.astro | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) rename astro/src/components/{Post.astro => PostEntry.astro} (91%) diff --git a/astro/src/components/Post.astro b/astro/src/components/PostEntry.astro similarity index 91% rename from astro/src/components/Post.astro rename to astro/src/components/PostEntry.astro index 92d0071..9eebf7f 100644 --- a/astro/src/components/Post.astro +++ b/astro/src/components/PostEntry.astro @@ -1,5 +1,10 @@ --- import { Image } from "@astrojs/image/components"; +import type { Post } from "@/types/payload-types"; + +interface Props { + post: Post; +} const { post } = Astro.props; --- diff --git a/astro/src/components/Posts.astro b/astro/src/components/Posts.astro index 7ea4b60..ce5fe9f 100644 --- a/astro/src/components/Posts.astro +++ b/astro/src/components/Posts.astro @@ -1,5 +1,10 @@ --- -import Post from "@/components/Post.astro" +import PostEntry from "@/components/PostEntry.astro" +import type { Post } from "@/types/payload-types"; + +interface Props { + posts: Post[]; +} const { posts } = Astro.props; --- @@ -10,8 +15,9 @@ const { posts } = Astro.props; { posts.length > 0 ? ( posts.map((post) => ( - - )) + typeof(post) === 'object') && + + ) ) : (

No posts available

)