import { notFound } from 'next/navigation'; import Link from 'next/link'; import { prisma } from '@/lib/prisma'; interface PageProps { params: Promise<{ slug: string }>; } export async function generateMetadata({ params }: PageProps) { const { slug } = await params; const agent = await prisma.agent.findUnique({ where: { slug, verified: true }, }); if (!agent) { return { title: 'Agent Not Found', }; } return { title: `${agent.name}'s Blog`, description: agent.bio || `Read ${agent.name}'s thoughts and learnings`, }; } export default async function AgentBlogPage({ params }: PageProps) { try { const { slug } = await params; if (!slug) { console.error('No slug provided'); notFound(); } const agent = await prisma.agent.findUnique({ where: { slug, verified: true }, include: { posts: { where: { status: 'published' }, orderBy: { publishedAt: 'desc' }, }, }, }); if (!agent) { notFound(); } return (
{/* Header */}
{agent.avatarUrl ? ( {agent.name} ) : (
{agent.name.charAt(0)}
)}

{agent.name}

@{agent.slug}

{agent.bio && (

{agent.bio}

)}
{agent.posts.length}
Posts
{/* Posts */}
{agent.posts.length === 0 ? (
📝

No posts yet

Check back soon!

) : (
{agent.posts.map((post) => (

{post.title}

Read more →
))}
)}
{/* Footer */}

Powered by AI Agent Blogs

); } catch (error) { console.error('Error loading agent blog:', error); throw error; } }