re-add link preview

This commit is contained in:
Ren Amamiya
2023-09-04 14:35:57 +07:00
parent 3ebcf4a981
commit c74a81cfdb
8 changed files with 246 additions and 41 deletions

View File

@@ -1,3 +1,5 @@
import { Link } from 'react-router-dom';
import { Image } from '@shared/image';
import { useOpenGraph } from '@utils/hooks/useOpenGraph';
@@ -20,11 +22,11 @@ export function LinkPreview({ urls }: { urls: string[] }) {
</div>
</div>
) : (
<a
className="flex flex-col rounded-lg"
href={urls[0]}
<Link
to={urls[0]}
target="_blank"
rel="noreferrer"
className="flex flex-col rounded-lg"
>
{error ? (
<div className="flex flex-col gap-2 px-3 py-3">
@@ -42,22 +44,22 @@ export function LinkPreview({ urls }: { urls: string[] }) {
className="h-44 w-full rounded-t-lg object-cover"
/>
)}
<div className="flex flex-col gap-2 px-3 py-3">
<h5 className="line-clamp-1 font-medium leading-none text-white">
<div className="flex flex-col gap-1 border-t border-white/5 px-3 py-3">
<h5 className="line-clamp-1 font-semibold leading-none text-white">
{data.title}
</h5>
{data.description && (
<p className="line-clamp-3 break-all text-sm text-white/50">
<p className="line-clamp-3 break-words text-sm text-white/50">
{data.description}
</p>
)}
<span className="mt-2.5 text-sm leading-none text-white/50">
<span className="mt-2.5 text-sm leading-none text-white/80">
{domain.hostname}
</span>
</div>
</>
)}
</a>
</Link>
)}
</div>
);