Spaces:
Sleeping
Sleeping
MingruiZhang
commited on
Commit
•
fdc5ed2
1
Parent(s):
76fdff4
fix build
Browse files- .gitignore +3 -0
- app/share/[id]/page.tsx +41 -41
.gitignore
CHANGED
@@ -36,3 +36,6 @@ yarn-error.log*
|
|
36 |
.vercel
|
37 |
.vscode
|
38 |
.env*.local
|
|
|
|
|
|
|
|
36 |
.vercel
|
37 |
.vscode
|
38 |
.env*.local
|
39 |
+
|
40 |
+
# ts
|
41 |
+
tsconfig.tsbuildinfo
|
app/share/[id]/page.tsx
CHANGED
@@ -1,48 +1,48 @@
|
|
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 |
-
|
|
|
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} />
|
45 |
+
</div>
|
46 |
+
</>
|
47 |
+
)
|
48 |
+
}
|