aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared-react/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared-react/utils')
-rw-r--r--packages/shared-react/utils/bookmarkUtils.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/shared-react/utils/bookmarkUtils.ts b/packages/shared-react/utils/bookmarkUtils.ts
index e7322712..0a089f64 100644
--- a/packages/shared-react/utils/bookmarkUtils.ts
+++ b/packages/shared-react/utils/bookmarkUtils.ts
@@ -38,3 +38,16 @@ export function isBookmarkStillTagging(bookmark: ZBookmark) {
export function isBookmarkStillLoading(bookmark: ZBookmark) {
return isBookmarkStillTagging(bookmark) || isBookmarkStillCrawling(bookmark);
}
+
+export function getSourceUrl(bookmark: ZBookmark) {
+ if (bookmark.content.type === BookmarkTypes.LINK) {
+ return bookmark.content.url;
+ }
+ if (bookmark.content.type === BookmarkTypes.ASSET) {
+ return bookmark.content.sourceUrl ?? null;
+ }
+ if (bookmark.content.type === BookmarkTypes.TEXT) {
+ return bookmark.content.sourceUrl ?? null;
+ }
+ return null;
+}