+ },
+
+ getTitle(posts) {
+
+ if (posts.length === 1) {
+ return `Link: ${posts[0].title}`;
+ }
+ return `${posts.length} links for ${internals.date}`;
+ },
+
+ slugify(text) {
+
+ return text.toLowerCase().replace(/[^a-z0-9 ]/g, '').replace(/ +/g, '-')
+ },
+
+ async toot(title) {
+
+ const body = new FormData();
+ body.set(
+ 'status',
+ `New post: ${title}\n\nAvailable on:\n\nāļø the gemini archive ${internals.archivePublicUrl}\n\n or, the ephemeral blog š: ${internals.blogPublicUrl}`
+ );
+ return fetch(`https://${internals.mastodonDomain}/api/v1/statuses`, {
+ method: 'POST',
+ headers: {
+ Authorization: `Bearer ${internals.tootToken}`,
+ },
+ body
+ });
+ },
+
+ async getBookmarks() {
+
+ const url = join(internals.apiUrl, 'bookmarks') + '?q=%23linkblog';
+ const response = await fetch(url, {
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Token ${internals.apiToken}`
+ }
+ });
+ const data = await response.json();
+
+ return data.results;
+ },
+
+ 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',
+ body: JSON.stringify(
+ {
+ tag_names: bookmark.tag_names.map((tag) => tag === 'linkblog' ? 'linkblog-posted' : tag)
+ }
+ ),
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Token ${internals.apiToken}`
+ }
+ });