diff options
| author | MohamedBassem <me@mbassem.com> | 2024-10-05 18:16:19 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-10-05 18:16:46 +0000 |
| commit | b147c8e5df75bdeafb1f0eeb2e6ce08e0dec7e37 (patch) | |
| tree | 1bfae4f49f8aeaf3870573831fdb62921ec38dd4 /packages/shared-react/utils | |
| parent | f1c956a361539592d00836488181b69218798600 (diff) | |
| download | karakeep-b147c8e5df75bdeafb1f0eeb2e6ce08e0dec7e37.tar.zst | |
feature: Persevere the source URL of clipped texts from the extension.
Fixes #448
Diffstat (limited to 'packages/shared-react/utils')
| -rw-r--r-- | packages/shared-react/utils/bookmarkUtils.ts | 13 |
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; +} |
