mirror of
https://github.com/svemagie/indiekit-endpoint-blogroll.git
synced 2026-04-02 15:34:59 +02:00
feat: use bookmark post category as blogroll category
This commit is contained in:
@@ -14,9 +14,10 @@ import { upsertBlog } from "./storage/blogs.js";
|
|||||||
*
|
*
|
||||||
* @param {object} application - Indiekit application object
|
* @param {object} application - Indiekit application object
|
||||||
* @param {string} bookmarkUrl - The URL that was bookmarked (bookmark-of value)
|
* @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 }
|
* @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
|
// Normalise: bookmark-of may be an array in some micropub clients
|
||||||
const url = Array.isArray(bookmarkUrl) ? bookmarkUrl[0] : bookmarkUrl;
|
const url = Array.isArray(bookmarkUrl) ? bookmarkUrl[0] : bookmarkUrl;
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ export async function importBookmarkUrl(application, bookmarkUrl) {
|
|||||||
feedUrl: feed.url,
|
feedUrl: feed.url,
|
||||||
siteUrl,
|
siteUrl,
|
||||||
feedType: feed.type || "rss",
|
feedType: feed.type || "rss",
|
||||||
category: "bookmarks",
|
category,
|
||||||
source: "bookmark",
|
source: "bookmark",
|
||||||
sourceId: null,
|
sourceId: null,
|
||||||
status: "active",
|
status: "active",
|
||||||
@@ -71,7 +72,7 @@ export async function importBookmarkUrl(application, bookmarkUrl) {
|
|||||||
|
|
||||||
if (result.upserted) {
|
if (result.upserted) {
|
||||||
console.log(
|
console.log(
|
||||||
`[Blogroll] bookmark-import: added ${feed.url} ("${discovery.pageTitle || siteUrl}")`
|
`[Blogroll] bookmark-import: added ${feed.url} ("${discovery.pageTitle || siteUrl}") → category "${category}"`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user