From 27b3f9d17958d76ced902787e387c15db720af0a Mon Sep 17 00:00:00 2001
From: Patrick Leonard <patrickleonardiii@gmail.com>
Date: Sun, 29 Dec 2024 04:25:56 -1000
Subject: feat: add Linkwarden importer (#786)

* added in Linkwarden import

* simpler parsing

---------

Co-authored-by: Mohamed Bassem <me@mbassem.com>
---
 apps/web/components/settings/ImportExport.tsx | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

(limited to 'apps/web/components/settings/ImportExport.tsx')

diff --git a/apps/web/components/settings/ImportExport.tsx b/apps/web/components/settings/ImportExport.tsx
index 34e069da..e38f629a 100644
--- a/apps/web/components/settings/ImportExport.tsx
+++ b/apps/web/components/settings/ImportExport.tsx
@@ -11,6 +11,7 @@ import { useTranslation } from "@/lib/i18n/client";
 import {
   ParsedBookmark,
   parseHoarderBookmarkFile,
+  parseLinkwardenBookmarkFile,
   parseNetscapeBookmarkFile,
   parseOmnivoreBookmarkFile,
   parsePocketBookmarkFile,
@@ -121,7 +122,7 @@ export function ImportExportRow() {
       source,
     }: {
       file: File;
-      source: "html" | "pocket" | "omnivore" | "hoarder";
+      source: "html" | "pocket" | "omnivore" | "hoarder" | "linkwarden";
     }) => {
       if (source === "html") {
         return await parseNetscapeBookmarkFile(file);
@@ -131,6 +132,8 @@ export function ImportExportRow() {
         return await parseHoarderBookmarkFile(file);
       } else if (source === "omnivore") {
         return await parseOmnivoreBookmarkFile(file);
+      } else if (source === "linkwarden") {
+        return await parseLinkwardenBookmarkFile(file);
       } else {
         throw new Error("Unknown source");
       }
@@ -230,6 +233,18 @@ export function ImportExportRow() {
           <Upload />
           <p>{t("settings.import.import_bookmarks_from_omnivore_export")}</p>
         </FilePickerButton>
+        <FilePickerButton
+          loading={false}
+          accept=".json"
+          multiple={false}
+          className="flex items-center gap-2"
+          onFileSelect={(file) =>
+            runUploadBookmarkFile({ file, source: "linkwarden" })
+          }
+        >
+          <Upload />
+          <p>{t("settings.import.import_bookmarks_from_linkwarden_export")}</p>
+        </FilePickerButton>
         <FilePickerButton
           loading={false}
           accept=".json"
-- 
cgit v1.2.3-70-g09d2

