aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared-react/utils
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2025-04-07 01:03:26 +0100
committerMohamedBassem <me@mbassem.com>2025-04-08 03:48:12 -0700
commit3207264fc13c275d6dcfbd2628cc6b3974ceeaed (patch)
treed426ffe0fe6bc3b9e692d96af94aa8d5d2a51162 /packages/shared-react/utils
parent817eb58832a3e715e21892417b7624f4b1cf0d46 (diff)
downloadkarakeep-3207264fc13c275d6dcfbd2628cc6b3974ceeaed.tar.zst
feat: Allow editing bookmark details
Diffstat (limited to 'packages/shared-react/utils')
-rw-r--r--packages/shared-react/utils/bookmarkUtils.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/shared-react/utils/bookmarkUtils.ts b/packages/shared-react/utils/bookmarkUtils.ts
index 0a089f64..fc0fd97d 100644
--- a/packages/shared-react/utils/bookmarkUtils.ts
+++ b/packages/shared-react/utils/bookmarkUtils.ts
@@ -51,3 +51,20 @@ export function getSourceUrl(bookmark: ZBookmark) {
}
return null;
}
+
+export function getBookmarkTitle(bookmark: ZBookmark) {
+ let title: string | null = null;
+ switch (bookmark.content.type) {
+ case BookmarkTypes.LINK:
+ title = bookmark.content.title ?? bookmark.content.url;
+ break;
+ case BookmarkTypes.TEXT:
+ title = null;
+ break;
+ case BookmarkTypes.ASSET:
+ title = bookmark.content.fileName ?? null;
+ break;
+ }
+
+ return bookmark.title ? bookmark.title : title;
+}