feat: use bookmark post category as blogroll category

This commit is contained in:
svemagie
2026-03-10 19:51:08 +01:00
parent 34739735e7
commit adbdadd508

View File

@@ -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<object>} 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 };
}
}