diff options
Diffstat (limited to 'packages/shared-react/utils')
| -rw-r--r-- | packages/shared-react/utils/bookmarkUtils.ts | 17 |
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; +} |
