apiToken: process.env.PINBOARD_TOKEN,
blogUrl: process.env.BLOG_URL,
archiveUrl: process.env.ARCHIVE_URL,
+ blogPublicUrl: process.env.BLOG_PUBLIC_URL,
+ archivePublicUrl: process.env.ARCHIVE_PUBLIC_URL,
+ tootToken: process.env.TOOT_TOKEN,
+ mastodonDomain: process.env.MASTODON_DOMAIN,
date: (new Date()).toISOString().split('T')[0],
getText(posts) {
- const linkText = posts.map((post) => {
+ return posts.map((post) => {
return `=> ${post.href} ${post.description}\n${post.extended}`;
}).join('\n\n');
getTitle(posts) {
if (posts.length === 1) {
- return posts[0].description;
+ return `Link: ${posts[0].description}`;
}
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
+ });
}
+
};
return;
}
- const title = internals.getTitle(posts);
- const text = internals.getText(posts);
+ const title = internals.getTitle(pins);
+ const text = internals.getText(pins);
const gemtext = internals.generateGemtext(title, text);
const filename = internals.slugify(title);
tags: pin.tags.replace('linkblog', 'linkblog-posted')
});
}
+
+ if (internals.tootToken) {
+ await internals.toot(title);
+ }
}
run()