aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/shared-react/utils/bookmarkUtils.ts17
-rw-r--r--packages/shared/types/bookmarks.ts10
2 files changed, 27 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;
+}
diff --git a/packages/shared/types/bookmarks.ts b/packages/shared/types/bookmarks.ts
index af7474ad..883dda30 100644
--- a/packages/shared/types/bookmarks.ts
+++ b/packages/shared/types/bookmarks.ts
@@ -196,6 +196,16 @@ export const zUpdateBookmarksRequestSchema = z.object({
note: z.string().optional(),
title: z.string().max(MAX_TITLE_LENGTH).nullish(),
createdAt: z.coerce.date().optional(),
+ // Link specific fields (optional)
+ url: z.string().url().optional(),
+ description: z.string().nullish(),
+ author: z.string().nullish(),
+ publisher: z.string().nullish(),
+ datePublished: z.coerce.date().nullish(),
+ dateModified: z.coerce.date().nullish(),
+
+ // Text specific fields (optional)
+ text: z.string().nullish(),
});
export type ZUpdateBookmarksRequest = z.infer<
typeof zUpdateBookmarksRequestSchema