page.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import Link from "next/link";
  2. import { Button, Card, CardBody, CardFooter } from "@nextui-org/react";
  3. import { RxCross2 } from "react-icons/rx";
  4. import Image from "next/image";
  5. import { customMapImageUrl, getAllBlogPosts } from "@/lib/notion";
  6. import { notionBlogConfig } from "@/config/site";
  7. export const revalidate = 0;
  8. const Page = async () => {
  9. const blogPosts = await getAllBlogPosts(notionBlogConfig.blogParentId);
  10. return (
  11. <div className="px-4 pb-10">
  12. <div className="flex flex-col items-center mb-4 gap-2">
  13. <Link href="/" prefetch={true}>
  14. <Button
  15. isIconOnly
  16. className="dark:border-knight dark:bg-transparent dark:border-2 bg-[#ece7e7] border-0"
  17. radius="full"
  18. variant="bordered"
  19. >
  20. <RxCross2 />
  21. </Button>
  22. </Link>
  23. <h1 className="text-2xl font-[500]">My Blog</h1>
  24. </div>
  25. <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
  26. {blogPosts.map(({ id, title, block, pageCover, createdAt }) => (
  27. <Link key={id} href={`/blog/${id}`}>
  28. <Card className="dark:bg-darkBg dark:border-2 dark:border-knight rounded-[2rem]">
  29. <CardBody className="p-0">
  30. <Image
  31. alt="cover"
  32. className="rounded-b-none object-cover h-[200px]"
  33. height={500}
  34. src={customMapImageUrl(pageCover, block)}
  35. width={500}
  36. />
  37. </CardBody>
  38. <CardFooter className="flex justify-between">
  39. <h3 className="font-[500] text-lg">{title}</h3>
  40. <h3 className="text-sm">{createdAt.toDateString()}</h3>
  41. </CardFooter>
  42. </Card>
  43. </Link>
  44. ))}
  45. </div>
  46. </div>
  47. );
  48. };
  49. export default Page;