blob: d61b1ed63299469d465fc30c44a0c55c0e3a5168 (
plain) (
blame)
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
50
51
52
|
"use client"
import { useState } from "react"
import type { DocumentsWithMemoriesResponseSchema } from "@repo/validation/api"
import type { z } from "zod"
import { dmSansClassName } from "@/utils/fonts"
import { cn } from "@lib/utils"
type DocumentsResponse = z.infer<typeof DocumentsWithMemoriesResponseSchema>
type DocumentWithMemories = DocumentsResponse["documents"][0]
export function WebsitePreview({
document,
}: {
document: DocumentWithMemories
}) {
const [imageError, setImageError] = useState(false)
const ogImage = (document as DocumentWithMemories & { ogImage?: string })
.ogImage
return (
<div className="bg-[#0B1017] rounded-[18px] overflow-hidden">
{ogImage && !imageError ? (
<div className="relative w-full aspect-video bg-gray-100 overflow-hidden">
<img
src={ogImage}
alt={document.title || "Website preview"}
className="w-full h-full object-cover"
onError={() => setImageError(true)}
loading="lazy"
/>
</div>
) : (
<div className="p-3 gap-2">
<p
className={cn(
dmSansClassName(),
"text-[12px] font-semibold text-[#E5E5E5] line-clamp-2 mb-1",
)}
>
{document.title || "Untitled Document"}
</p>
{document.content && (
<p className="text-[10px] text-[#737373] line-clamp-3">
{document.content}
</p>
)}
</div>
)}
</div>
)
}
|