microblog/app/posts.tsx

25 lines
544 B
TypeScript
Raw Normal View History

2022-11-06 21:07:22 +01:00
import { getPosts, Post } from '@/lib/getPosts';
import { FC, use } from 'react';
interface PostProps {
posts: Post[];
}
const Posts: FC<PostProps> = ({ posts }) => {
return (
<>
{posts.map((p) => (
<div className="space-y-2 text-white">
<p className="font-bold">{p.author.name}</p>
<p>{p.title}</p>
{p.message &&
p.message
.split('\n')
.map((para, i) => para && <p key={i}>{para}</p>)}
</div>
))}
</>
);
};
export default Posts;