diff --git a/lib/bookmark-import.js b/lib/bookmark-import.js index 4b9b1da..2675d77 100644 --- a/lib/bookmark-import.js +++ b/lib/bookmark-import.js @@ -14,9 +14,10 @@ import { upsertBlog } from "./storage/blogs.js"; * * @param {object} application - Indiekit application object * @param {string} bookmarkUrl - The URL that was bookmarked (bookmark-of value) + * @param {string} [category="bookmarks"] - Category to assign in the blogroll * @returns {Promise} Result { added, alreadyExists, noFeeds, error } */ -export async function importBookmarkUrl(application, bookmarkUrl) { +export async function importBookmarkUrl(application, bookmarkUrl, category = "bookmarks") { // Normalise: bookmark-of may be an array in some micropub clients const url = Array.isArray(bookmarkUrl) ? bookmarkUrl[0] : bookmarkUrl; @@ -63,7 +64,7 @@ export async function importBookmarkUrl(application, bookmarkUrl) { feedUrl: feed.url, siteUrl, feedType: feed.type || "rss", - category: "bookmarks", + category, source: "bookmark", sourceId: null, status: "active", @@ -71,9 +72,9 @@ export async function importBookmarkUrl(application, bookmarkUrl) { if (result.upserted) { console.log( - `[Blogroll] bookmark-import: added ${feed.url} ("${discovery.pageTitle || siteUrl}")` + `[Blogroll] bookmark-import: added ${feed.url} ("${discovery.pageTitle || siteUrl}") → category "${category}"` ); } return { added: result.upserted ? 1 : 0, siteUrl }; -} +} \ No newline at end of file