mirror of
https://github.com/svemagie/indiekit-endpoint-blogroll.git
synced 2026-04-02 15:34:59 +02:00
feat: pass bookmark post category through to blogroll entry
This commit is contained in:
13
index.js
13
index.js
@@ -40,8 +40,19 @@ bookmarkHookRouter.use((request, response, next) => {
|
||||
request.body?.properties?.["bookmark-of"]?.[0];
|
||||
if (!bookmarkOf) return;
|
||||
|
||||
// Extract category from any micropub body format:
|
||||
// form-encoded: category=tech or category[]=tech&category[]=web
|
||||
// JF2 JSON: { "category": ["tech", "web"] }
|
||||
// MF2 JSON: { "properties": { "category": ["tech"] } }
|
||||
const rawCategory =
|
||||
request.body?.category ||
|
||||
request.body?.properties?.category;
|
||||
const category = Array.isArray(rawCategory)
|
||||
? rawCategory[0] || "bookmarks"
|
||||
: rawCategory || "bookmarks";
|
||||
|
||||
const { application } = request.app.locals;
|
||||
importBookmarkUrl(application, bookmarkOf).catch((err) =>
|
||||
importBookmarkUrl(application, bookmarkOf, category).catch((err) =>
|
||||
console.warn("[Blogroll] bookmark-import failed:", err.message)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user