blog.hangerthem.com/components/post/RecentlyUpdatedPosts.tsx
2026-08-03 17:34:05 +02:00

27 lines
902 B
TypeScript

import { getAllPostsMeta } from '@/lib/posts'
import Link from 'next/link'
export function RecentlyUpdatedPosts() {
const posts = getAllPostsMeta()
return (
<aside className="w-80 xl:w-100 hidden lg:block">
<div className="sticky top-12 border-l border-border h-fit pl-4 py-4">
<h2 className="text-xl font-bold mb-4">Recently updated</h2>
<ul className="flex flex-col gap-2 ml-1">
{posts
.toSorted(
(a, b) =>
new Date(b.updated ?? b.date).getTime() - new Date(a.updated ?? a.date).getTime(),
)
.map((post) => (
<li key={post.slug} className="text-sm text-fg-dim">
<Link href={`/posts/${post.slug}`} className="hover:underline">
{post.title}
</Link>
</li>
))}
</ul>
</div>
</aside>
)
}