From 93630ce88dcb07bcdf7445185fe20612a5c22b7b Mon Sep 17 00:00:00 2001 From: Moondragon85 <42060641+Moondragon85@users.noreply.github.com> Date: Sat, 27 Dec 2025 12:52:37 +0100 Subject: feat: add Matter import support (#2245) * Matter import * use zod * fix date parsing --------- Co-authored-by: Mohamed Bassem --- apps/web/components/settings/ImportExport.tsx | 17 ++++++++ apps/web/lib/i18n/locales/ar/translation.json | 1 + apps/web/lib/i18n/locales/cs/translation.json | 1 + apps/web/lib/i18n/locales/da/translation.json | 1 + apps/web/lib/i18n/locales/de/translation.json | 1 + apps/web/lib/i18n/locales/el/translation.json | 1 + apps/web/lib/i18n/locales/en/translation.json | 1 + apps/web/lib/i18n/locales/en_US/translation.json | 1 + apps/web/lib/i18n/locales/es/translation.json | 1 + apps/web/lib/i18n/locales/fa/translation.json | 1 + apps/web/lib/i18n/locales/fi/translation.json | 1 + apps/web/lib/i18n/locales/fr/translation.json | 1 + apps/web/lib/i18n/locales/ga/translation.json | 1 + apps/web/lib/i18n/locales/gl/translation.json | 1 + apps/web/lib/i18n/locales/hr/translation.json | 1 + apps/web/lib/i18n/locales/hu/translation.json | 1 + apps/web/lib/i18n/locales/it/translation.json | 1 + apps/web/lib/i18n/locales/ja/translation.json | 1 + apps/web/lib/i18n/locales/ko/translation.json | 1 + apps/web/lib/i18n/locales/nb_NO/translation.json | 1 + apps/web/lib/i18n/locales/nl/translation.json | 1 + apps/web/lib/i18n/locales/pl/translation.json | 1 + apps/web/lib/i18n/locales/pt/translation.json | 1 + apps/web/lib/i18n/locales/pt_BR/translation.json | 1 + apps/web/lib/i18n/locales/ru/translation.json | 1 + apps/web/lib/i18n/locales/sk/translation.json | 1 + apps/web/lib/i18n/locales/sl/translation.json | 1 + apps/web/lib/i18n/locales/sv/translation.json | 1 + apps/web/lib/i18n/locales/tr/translation.json | 1 + apps/web/lib/i18n/locales/uk/translation.json | 1 + apps/web/lib/i18n/locales/vi/translation.json | 1 + apps/web/lib/i18n/locales/zh/translation.json | 1 + apps/web/lib/i18n/locales/zhtw/translation.json | 1 + packages/shared/import-export/parsers.ts | 50 ++++++++++++++++++++++++ 34 files changed, 99 insertions(+) diff --git a/apps/web/components/settings/ImportExport.tsx b/apps/web/components/settings/ImportExport.tsx index b6e4da9a..1cef8483 100644 --- a/apps/web/components/settings/ImportExport.tsx +++ b/apps/web/components/settings/ImportExport.tsx @@ -179,6 +179,23 @@ export function ImportExportRow() {

Import

+ + + runUploadBookmarkFile({ file, source: "matter" }) + } + > +

Import

+
+
(tags.length > 0 ? tags.split(";") : [])), + "Word Count": z.string(), + "In Queue": z.string().transform((inQueue) => inQueue === "False"), + Favorited: z.string(), + Read: z.string(), + Highlight_Count: z.string(), + "Last Interaction Date": z + .string() + .transform((date) => Date.parse(date) / 1000), + "File Id": z.string(), + }); + + const zMatterExportSchema = z.array(zMatterRecordSchema); + + const records = parse(textContent, { + columns: true, + skip_empty_lines: true, + }); + + const parsed = zMatterExportSchema.safeParse(records); + if (!parsed.success) { + throw new Error( + `The uploaded CSV file contains an invalid Matter bookmark file: ${parsed.error.toString()}`, + ); + } + + return parsed.data.map((record) => { + return { + title: record.Title, + content: { type: BookmarkTypes.LINK as const, url: record.URL }, + tags: record.Tags, + addDate: record["Last Interaction Date"], + archived: record["In Queue"], + paths: [], // TODO + }; + }); +} + function parseKarakeepBookmarkFile(textContent: string): ParsedBookmark[] { const parsed = zExportSchema.safeParse(JSON.parse(textContent)); if (!parsed.success) { @@ -347,6 +394,9 @@ export function parseImportFile( case "pocket": result = parsePocketBookmarkFile(textContent); break; + case "matter": + result = parseMatterBookmarkFile(textContent); + break; case "karakeep": result = parseKarakeepBookmarkFile(textContent); break; -- cgit v1.2.3-70-g09d2