Embedding Mastodon Feeds

Make this demo page usable on narrow devices.

The column on the left contains recent toots from two mastodon accounts while the column on the right contains recent toots with some hashtag. This is implemented by a web component using Mastodon's REST API.

The <mastodon-toots> component takes a single attribute url for retrieving the toots. You can use any URL of the mastodon API that provides a JSON array of "statuses" (= posts = toots). See the mastodon API docs on retrieving timelines and statuses.

For example:

The output of the component does not go to shadow DOM. So it can be styled with CSS for the main ("light") DOM tree.

The component only works if CORS is enabled by the server. All the mastodon servers I tried actually had this enabled.

Features that might be added:

Contributions and suggestions welcome! (To my mastodon account @hcschuetz@mastodon.social, in the discussion section of the github repo, or even as a pull request.)

I haven't npm-packaged the code (yet) because users of the component will probably want to tweak a few things here and there. I don't want to complicate the code by adding a lot of configurability. It should be easy for web developers to tweak their copy of the code directly. Furthermore such tweaks may depend on third-party code, but I'd like to avoid dependencies in the "vanilla" version.

Also notice that both the web component and the demo page run directly from the source code. There is no build step.

Similar Projects

There are various instructions and projects doing similar (but somewhat different) things. I am aware of these:

So you have to find your compromise between functionality and simplicity as well as between ready-made and easily adaptable code.