blob: 0233357cd53c9ed7982b72f89cd608f566a48815 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
"use client";
import Image from "next/image";
import Link from "next/link";
import { BookmarkMarkdownComponent } from "@/components/dashboard/bookmarks/BookmarkMarkdownComponent";
import { bookmarkLayoutSwitch } from "@/lib/userLocalSettings/bookmarksLayout";
import { cn } from "@/lib/utils";
import type { ZBookmarkTypeText } from "@karakeep/shared/types/bookmarks";
import { getAssetUrl } from "@karakeep/shared-react/utils/assetUtils";
import { getSourceUrl } from "@karakeep/shared-react/utils/bookmarkUtils";
import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard";
import FooterLinkURL from "./FooterLinkURL";
export default function TextCard({
bookmark,
className,
}: {
bookmark: ZBookmarkTypeText;
className?: string;
}) {
const banner = bookmark.assets.find((a) => a.assetType == "bannerImage");
return (
<>
<BookmarkLayoutAdaptingCard
title={bookmark.title}
content={
<BookmarkMarkdownComponent readOnly={true}>
{bookmark}
</BookmarkMarkdownComponent>
}
footer={
getSourceUrl(bookmark) && (
<FooterLinkURL url={getSourceUrl(bookmark)} />
)
}
wrapTags={true}
bookmark={bookmark}
className={className}
fitHeight={true}
image={(layout, className) =>
bookmarkLayoutSwitch(layout, {
grid: null,
masonry: null,
compact: null,
list: banner ? (
<div className="relative size-full flex-1">
<Link href={`/dashboard/preview/${bookmark.id}`}>
<Image
alt="card banner"
fill={true}
className={cn("flex-1", className)}
src={getAssetUrl(banner.id)}
/>
</Link>
</div>
) : (
<div
className={cn(
"flex size-full items-center justify-center bg-accent text-center",
className,
)}
>
Note
</div>
),
})
}
/>
</>
);
}
|