From: Ruben Beltran del Rio Date: Sat, 21 Sep 2024 18:51:21 +0000 (+0000) Subject: Adjust title logic X-Git-Url: https://git.r.bdr.sh/rbdr/linkding-linkblog-updater/commitdiff_plain Adjust title logic --- diff --git a/index.js b/index.js index ef06ad9..275b96c 100644 --- a/index.js +++ b/index.js @@ -26,14 +26,17 @@ const internals = { return posts.map((post) => { - return `=> ${post.url} ${post.title}\n${post.notes}`; + const title = post.title || post.website_title + return `=> ${post.url} ${title}\n${post.notes}`; }).join('\n\n'); }, getTitle(posts) { + const title = posts[0].title || posts[0].website_title + if (posts.length === 1) { - return `Link: ${posts[0].title}`; + return `Link: ${title}`; } return `${posts.length} links for ${internals.date}`; }, @@ -75,9 +78,6 @@ const internals = { async updateBookmark(bookmark) { - console.log(bookmark.tag_names); - console.log(bookmark.tag_names.map((tag) => tag === 'linkblog' ? 'linkblog-posted' : tag)); - const url = join(internals.apiUrl, 'bookmarks', `${bookmark.id}`) const response = await fetch(url, { method: 'PATCH', @@ -91,10 +91,6 @@ const internals = { Authorization: `Token ${internals.apiToken}` } }); - - const data = await response.text(); - console.log(url); - console.log(data); } };