aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/preview/TextContentSection.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-10-05 20:08:50 +0000
committerMohamedBassem <me@mbassem.com>2024-10-05 20:09:54 +0000
commit8a1309536b76ba86872ca2e78aa695d9fd80c8cc (patch)
tree23d67611b16ab85f45e917b46297831560447038 /apps/web/components/dashboard/preview/TextContentSection.tsx
parent99c6232fde898932d77bab166934f59d3c56d7d1 (diff)
downloadkarakeep-8a1309536b76ba86872ca2e78aa695d9fd80c8cc.tar.zst
feature: Allow attaching custom banners to notes. Fixes: #106
Diffstat (limited to 'apps/web/components/dashboard/preview/TextContentSection.tsx')
-rw-r--r--apps/web/components/dashboard/preview/TextContentSection.tsx18
1 files changed, 18 insertions, 0 deletions
diff --git a/apps/web/components/dashboard/preview/TextContentSection.tsx b/apps/web/components/dashboard/preview/TextContentSection.tsx
index 76cb23ea..327436c6 100644
--- a/apps/web/components/dashboard/preview/TextContentSection.tsx
+++ b/apps/web/components/dashboard/preview/TextContentSection.tsx
@@ -1,14 +1,32 @@
+import Image from "next/image";
import { MarkdownComponent } from "@/components/ui/markdown-component";
import { ScrollArea } from "@radix-ui/react-scroll-area";
+import { getAssetUrl } from "@hoarder/shared-react/utils/assetUtils";
import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks";
export function TextContentSection({ bookmark }: { bookmark: ZBookmark }) {
if (bookmark.content.type != BookmarkTypes.TEXT) {
throw new Error("Invalid content type");
}
+ const banner = bookmark.assets.find(
+ (asset) => asset.assetType == "bannerImage",
+ );
+
return (
<ScrollArea className="h-full">
+ {banner && (
+ <div className="relative h-52 min-w-full">
+ <Image
+ alt="banner"
+ src={getAssetUrl(banner.id)}
+ width={0}
+ height={0}
+ layout="fill"
+ objectFit="cover"
+ />
+ </div>
+ )}
<MarkdownComponent>{bookmark.content.text}</MarkdownComponent>
</ScrollArea>
);