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