Spaces:
Running
Running
File size: 1,190 Bytes
ee55c8c 76fdff4 ee55c8c f3a9ef2 76fdff4 fdc5ed2 ee55c8c fdc5ed2 76fdff4 fdc5ed2 ee55c8c fdc5ed2 ee55c8c 76fdff4 ee55c8c fdc5ed2 76fdff4 fdc5ed2 ee55c8c 76fdff4 ee55c8c 76fdff4 ee55c8c fdc5ed2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import { type Metadata } from 'next';
import { notFound } from 'next/navigation';
import { formatDate } from '@/lib/utils';
import { getSharedChat } from '@/app/actions';
import { ChatList } from '@/components/chat/ChatList';
interface SharePageProps {
params: {
id: string;
};
}
export async function generateMetadata({
params,
}: SharePageProps): Promise<Metadata> {
const chat = await getSharedChat(params.id);
return {
title: chat?.title.slice(0, 50) ?? 'Chat',
};
}
export default async function SharePage({ params }: SharePageProps) {
const chat = await getSharedChat(params.id);
if (!chat || !chat?.sharePath) {
notFound();
}
return (
<>
<div className="flex-1 space-y-6">
<div className="px-4 py-6 border-b bg-background md:px-6 md:py-8">
<div className="max-w-2xl mx-auto md:px-6">
<div className="space-y-1 md:-mx-8">
<h1 className="text-2xl font-bold">{chat.title}</h1>
<div className="text-sm text-muted-foreground">
{formatDate(chat.createdAt)} · {chat.messages.length} messages
</div>
</div>
</div>
</div>
<ChatList messages={chat.messages} isLoading={false} />
</div>
</>
);
}
|