Files
nocturne/app/blog/page.tsx
T
2024-05-29 18:35:53 +08:00

33 lines
940 B
TypeScript

import React from 'react';
import fetch_posts_list from '@/app/blog/fetch_posts_list';
import BlogPostCard from '@/app/blog/BlogPostCard';
import { Card, CardBody } from '@nextui-org/card';
async function Blog() {
try {
const res = await fetch_posts_list();
let posts = res['posts'];
return (
// blog list
<ul className={ 'flex flex-col items-center w-full space-y-7' }>
{ posts.map((post: JSON, key: React.Key | null | undefined) => (
<li key={ key } className={ 'w-full' }>
<BlogPostCard post={ post } />
</li>)
) }
</ul>
);
} catch (e: any) {
return (
<Card className={ `w-full` }>
<CardBody>
Fatal: Failed to load post list.
</CardBody>
</Card>);
}
}
export default Blog;