aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/lib/importBookmarkParser.ts
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2025-05-24 10:31:53 +0100
committerMohamedBassem <me@mbassem.com>2025-05-24 10:31:53 +0100
commitc6d21afa17775270bb8e65dd1b6df09023147f01 (patch)
treee305a3cafcf0a2796db2c8d22da7950e353343f6 /apps/web/lib/importBookmarkParser.ts
parent6af14e9d0ab76ad2a1b92e0072d8242129910d3e (diff)
downloadkarakeep-c6d21afa17775270bb8e65dd1b6df09023147f01.tar.zst
feat: Read the archive status from omnivore and pocket. Fixes #703
Diffstat (limited to 'apps/web/lib/importBookmarkParser.ts')
-rw-r--r--apps/web/lib/importBookmarkParser.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/apps/web/lib/importBookmarkParser.ts b/apps/web/lib/importBookmarkParser.ts
index a97e4da9..aba11689 100644
--- a/apps/web/lib/importBookmarkParser.ts
+++ b/apps/web/lib/importBookmarkParser.ts
@@ -15,6 +15,7 @@ export interface ParsedBookmark {
tags: string[];
addDate?: number;
notes?: string;
+ archived?: boolean;
}
export async function parseNetscapeBookmarkFile(
@@ -64,6 +65,7 @@ export async function parsePocketBookmarkFile(
url: string;
time_added: string;
tags: string;
+ status?: string;
}[];
return records.map((record) => {
@@ -72,6 +74,7 @@ export async function parsePocketBookmarkFile(
content: { type: BookmarkTypes.LINK as const, url: record.url },
tags: record.tags.length > 0 ? record.tags.split("|") : [],
addDate: parseInt(record.time_added),
+ archived: record.status === "archive",
};
});
}
@@ -107,6 +110,7 @@ export async function parseKarakeepBookmarkFile(
tags: bookmark.tags,
addDate: bookmark.createdAt,
notes: bookmark.note ?? undefined,
+ archived: bookmark.archived,
};
});
}
@@ -121,6 +125,7 @@ export async function parseOmnivoreBookmarkFile(
url: z.string(),
labels: z.array(z.string()),
savedAt: z.coerce.date(),
+ state: z.string().optional(),
}),
);
@@ -137,6 +142,7 @@ export async function parseOmnivoreBookmarkFile(
content: { type: BookmarkTypes.LINK as const, url: bookmark.url },
tags: bookmark.labels,
addDate: bookmark.savedAt.getTime() / 1000,
+ archived: bookmark.state === "Archived",
};
});
}
@@ -242,6 +248,10 @@ export function deduplicateBookmarks(
} else if (bookmark.notes) {
existing.notes = bookmark.notes;
}
+ // For archived status, prefer archived if either is archived
+ if (bookmark.archived === true) {
+ existing.archived = true;
+ }
// Title: keep existing one for simplicity
} else {
deduplicatedBookmarksMap.set(url, bookmark);