From 61bb02110ccebbbd78119dd490716637ec86419b Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Wed, 16 Oct 2024 00:02:25 -0400
Subject: Refactor

---
 extension/src/Bookmark.tsx | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

(limited to 'extension/src/Bookmark.tsx')

diff --git a/extension/src/Bookmark.tsx b/extension/src/Bookmark.tsx
index d9652a4..c555ffb 100644
--- a/extension/src/Bookmark.tsx
+++ b/extension/src/Bookmark.tsx
@@ -1,16 +1,21 @@
-interface BookmarkProps {
-    name: string;
-    url: string;
-    icon: string;
-}
+import BookmarkTreeNode = chrome.bookmarks.BookmarkTreeNode;
 
-function Bookmark(props: BookmarkProps) {
+function Bookmark(props: {data: BookmarkTreeNode}) {
     return(
-        <a className="bookmark" href={props.url}>
-            <img alt="Bookmark icon" src={props.icon}></img>
-            <span>{props.name}</span>
+        <a className="bookmark" href={props.data.url}>
+            <img alt="Bookmark icon" src={faviconURL(props.data.url)}></img>
+            <span>{props.data.title}</span>
         </a>
     );
 }
 
+function faviconURL(u: string | undefined) {
+    if (!u) return "";
+    u = new URL(u).origin.toString();
+    const url = new URL(chrome.runtime.getURL("/_favicon/"));
+    url.searchParams.set("pageUrl", u);
+    url.searchParams.set("size", "32");
+    return url.toString();
+}
+
 export default Bookmark;
\ No newline at end of file
-- 
cgit v1.2.3

