From ecb13cec5d5c646308b34c714401a716f3cdf199 Mon Sep 17 00:00:00 2001
From: Rodrigo Santos <rr.santos1232@gmail.com>
Date: Sun, 13 Jul 2025 23:45:06 +0100
Subject: feat: markdown file upload support (#1647) (#1672)

* feat: Add support for uploading Markdown (.md) files

* add: markdown to supported bookmark assets

* revert the changes in the assetdb

---------

Co-authored-by: Mohamed Bassem <me@mbassem.com>
---
 apps/web/components/dashboard/UploadDropzone.tsx | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

(limited to 'apps/web/components/dashboard/UploadDropzone.tsx')

diff --git a/apps/web/components/dashboard/UploadDropzone.tsx b/apps/web/components/dashboard/UploadDropzone.tsx
index df7bae0a..2bac005e 100644
--- a/apps/web/components/dashboard/UploadDropzone.tsx
+++ b/apps/web/components/dashboard/UploadDropzone.tsx
@@ -45,8 +45,25 @@ export function useUploadAsset() {
   });
 
   return useCallback(
-    (file: File) => {
-      return runUploadAsset(file);
+    async (file: File) => {
+      // Handle markdown files as text bookmarks
+      if (file.type === "text/markdown" || file.name.endsWith(".md")) {
+        try {
+          const content = await file.text();
+          await createBookmark({
+            type: BookmarkTypes.TEXT,
+            text: content,
+            title: file.name.replace(/\.md$/i, ""), // Remove .md extension from title
+          });
+        } catch {
+          toast({
+            description: `${file.name}: Failed to read markdown file`,
+            variant: "destructive",
+          });
+        }
+      } else {
+        return runUploadAsset(file);
+      }
     },
     [runUploadAsset],
   );
@@ -134,7 +151,7 @@ export default function UploadDropzone({
               </div>
             ) : (
               <p className="text-2xl font-bold text-gray-700">
-                Drop Your Image / Bookmark file
+                Drop Your Image / PDF / Markdown file
               </p>
             )}
           </div>
-- 
cgit v1.2.3-70-g09d2

