import type { Metadata } from "next"; import Link from "next/link"; import { StatusBadge } from "@/components/admin/StatusBadge"; import { LinkButton } from "@/components/ui"; import { requireAdmin } from "@/lib/auth/dal"; import { formatDate } from "@/lib/format"; import { listAllPages } from "@/lib/services/pages"; import { countPostsByStatus, listAllPosts } from "@/lib/services/posts"; import { listAllTags } from "@/lib/services/tags"; export const metadata: Metadata = { title: "Dashboard" }; export default async function AdminDashboard() { await requireAdmin(); const [postCounts, allPosts, allPages, allTags] = await Promise.all([ countPostsByStatus(), listAllPosts(), listAllPages(), listAllTags(), ]); const recentPosts = allPosts.slice(0, 5); const stats = [ { label: "Published posts", value: postCounts.published }, { label: "Draft posts", value: postCounts.draft }, { label: "Pages", value: allPages.length }, { label: "Tags", value: allTags.length }, ]; return (

Dashboard

New post New page
{stats.map((stat) => (
{stat.label}
{stat.value}
))}

Recently updated posts

{recentPosts.length === 0 ? (

No posts yet —{" "} write the first one .

) : ( )}
); }