Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

final touch

daniel31x1372266d1cd509
diff --git a/lib/api/controllers/migration/importFromHTMLFile.ts b/lib/api/controllers/migration/importFromHTMLFile.ts
index c557133d..43986007 100644
--- a/lib/api/controllers/migration/importFromHTMLFile.ts
+++ b/lib/api/controllers/migration/importFromHTMLFile.ts
@@ -36,8 +36,6 @@ export default async function importFromHTMLFile(
const jsonData = parse(document.documentElement.outerHTML);
- // console.log(jsonData);
-
for (const item of jsonData) {
console.log(item);
await processBookmarks(userId, item as Element);
@@ -54,15 +52,13 @@ async function processBookmarks(
if (data.type === "element") {
for (const item of data.children) {
if (item.type === "element" && item.tagName === "dt") {
+ // process collection or sub-collection
+
let collectionId;
const collectionName = item.children.find(
(e) => e.type === "element" && e.tagName === "h3"
) as Element;
- console.log("collection:", item);
- console.log("collectionName:", collectionName);
-
- // This is a collection or sub-collection
if (collectionName) {
collectionId = await createCollection(
userId,
@@ -76,23 +72,16 @@ async function processBookmarks(
collectionId || parentCollectionId
);
} else if (item.type === "element" && item.tagName === "a") {
- // This is a link
+ // process link
- // get link href
const linkUrl = item?.attributes.find((e) => e.key === "href")?.value;
-
- // get link name
const linkName = (
item?.children.find((e) => e.type === "text") as TextNode
)?.content;
-
- // get link tags
const linkTags = item?.attributes
.find((e) => e.key === "tags")
?.value.split(",");
- console.log("link:", item);
-
if (linkUrl && parentCollectionId) {
await createLink(
userId,
@@ -118,11 +107,9 @@ async function processBookmarks(
await processBookmarks(userId, item, parentCollectionId);
} else {
- // This could be anything else
+ // process anything else
await processBookmarks(userId, item, parentCollectionId);
}
-
- // Add more conditions as necessary based on your JSON structure
}
}
}