Automate and syndicate content from Eleventy to Mastodon
I've discussed building a now page using Eleventy but I also syndicate a subset of that content out to Mastodon using @11ty/eleventy-activity-feed
and Make. The @11ty/eleventy-activity-feed
allows you to aggregate various web feeds into a single feed, inserting entries from the feeds sequentially as they're published. My follow-feed.11ty.js
looks like this:
module.exports = class {
data() {
return {
permalink: '/follow.xml',
}
}
async render() {
const { ActivityFeed } = await import('@11ty/eleventy-activity-feed')
const feed = new ActivityFeed()
feed.addSource('atom', 'Blog', 'https://coryd.dev/feed.xml')
feed.addSource('rss', 'Letterboxd', 'https://letterboxd.com/cdme/rss')
feed.addSource('rss', 'Glass', 'https://glass.photo/coryd/rss')
feed.addSource('rss', 'Oku', 'https://oku.club/rss/collection/NvEmF')
return feed.toRssFeed({
title: "Cory Dransfeldt's activity feed",
language: 'en',
url: 'https://coryd.dev/follow/',
subtitle: "Cory Dransfeldt's activity across the web.",
})
}
}
As I update the above feeds, my activity feed found at https://coryd.dev/follow.xml updates. My workflow at Make[1] watches /follow.xml
, checking it every 2 hours and posting the newest item title and url to Mastodon.
If you elect to use Make for something like this you'll need to leverage the RSS module, which I've configured to return a maximum of 3 items per check and either the Mastodon or HTTP module (I've used the latter as the former errored when accessing my instance). If you use the HTTP module, the configuration is fairly simple:
Log in to your instance, accessing the prefererences, then the
Development
menu.Create a new application, naming it whatever you'd like (mine is named coryd.dev[2]) with the
write:statuses
scope.Head back to Make, connecting an HTTP module to your RSS module.
Add a heading named
Authorization
with a value ofBearer <TOKEN OBTAINED FROM YOUR MASTODON INSTANCE>
Add a second heading named
Accept
with a value ofapplication/json
Set the body type to
Application/x-www-form-urlencoded
Add a field with the key set to
status
and the value to theTitle
andURL
data obtained from your RSS module.Save and schedule the scenario to run at your preferred frequency.
You should now see posts from your follow feed being sent off to your Mastodon instance as they're updated.
Subscribe to my newsletter
Read articles from Cory Dransfeldt directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Cory Dransfeldt
Cory Dransfeldt
Husband, dad, developer, music nerd.