Type posts

This commit is contained in:
tobias 2024-05-21 12:04:23 +02:00
parent 62e50496a2
commit 4b30d58db6
2 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,10 @@
--- ---
import { Image } from "@astrojs/image/components"; import { Image } from "@astrojs/image/components";
import type { Post } from "@/types/payload-types";
interface Props {
post: Post;
}
const { post } = Astro.props; const { post } = Astro.props;
--- ---

View File

@ -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; const { posts } = Astro.props;
--- ---
@ -10,8 +15,9 @@ const { posts } = Astro.props;
{ {
posts.length > 0 ? ( posts.length > 0 ? (
posts.map((post) => ( posts.map((post) => (
<Post post={post}/> typeof(post) === 'object') &&
)) <PostEntry post={post}/>
)
) : ( ) : (
<p>No posts available</p> <p>No posts available</p>
) )