page.tsx 548 B

123456789101112131415161718192021222324
  1. import { blogEnabled } from '@/config/site';
  2. import { allPosts } from 'contentlayer/generated';
  3. import { notFound } from 'next/navigation';
  4. export default async function BlogArchivePage() {
  5. const posts = allPosts.sort((a, b) => {
  6. return new Date(a.date).getTime() - new Date(b.date).getTime();
  7. }).reverse();
  8. if (!blogEnabled) {
  9. notFound();
  10. }
  11. return (
  12. <>
  13. {posts.map((post, i) => (
  14. <div key={post._id}>
  15. {post._id}
  16. <a href={post.slug}>{post.title}</a>
  17. </div>
  18. ))}
  19. </>
  20. );
  21. }