Files
blog-nextjs/app/page.tsx

45 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Link from 'next/link';
import { getAllPostsSorted } from '@/lib/posts';
import { siteConfig } from '@/lib/config';
export default function HomePage() {
const posts = getAllPostsSorted().slice(0, 5);
return (
<section className="space-y-6">
<div>
<h1 className="text-3xl font-bold">
{siteConfig.name}
</h1>
<p className="mt-2 text-gray-600 dark:text-gray-300">
Blog
</p>
</div>
<div>
<h2 className="text-xl font-semibold"></h2>
<ul className="mt-3 space-y-2">
{posts.map((post) => (
<li key={post._id}>
<Link href={post.url} className="hover:underline">
{post.title}
</Link>
{post.published_at && (
<span className="ml-2 text-xs text-gray-500">
{new Date(post.published_at).toLocaleDateString('zh-TW')}
</span>
)}
</li>
))}
</ul>
<Link
href="/blog"
className="mt-4 inline-block text-sm text-blue-600 hover:underline"
>
</Link>
</div>
</section>
);
}