Display posts from Mastodon on your Kirby-powered site. Includes a variety of configuration options and caching for improved performance.
kirby plugin:install scottboms/mastodon-feed$ git submodule add https://github.com/scottboms/kirby-mastodon-feed.git site/plugins/mostadon-feed- Download the contents of this repository as Zip file.
- Rename the extracted folder to
mastodon-feedand copy it into thesite/plugins/directory in your Kirby project.
Add the following line to include the built-in snippet to your site. You can customize the HTML formatting by creating a snippet with the same name in your /site/snippets/ folder.
<?= snippet('mastodon_feed') ?>If you want to explore the data returned via the plugin to the snippet or that you can render directly in a template, you can use the following to output the contents of the $feed object returned.
<pre>
<?php print_r($items->toArray()); ?>
</pre>| Property | Default | Req? | Description |
|---|---|---|---|
| cache.scottboms.mastodon.type | file |
Yes | Required to enable cache type for the plugin |
| username | null |
Yes | Your Mastodon username |
| server | null |
Yes | Your Mastodon server (e.g. mastodon.social) |
| cache | true |
No | Caches data returned from Mastodon API. |
| cachettl | 900 |
No | Cache timeout - 15 minutes default (900s) |
| limit | 20 |
No | Number of results to return/display (max 40) |
| dateformat | M d, Y |
No | Adjust date format per PHP datetime formats |
| excludereplies | true |
No | Exclude replies from results? |
| onlymedia | false |
No | Only show posts with media attachments? |
| panel.limit | 12 |
No | Number of results to display in the Panel Area |
Date formatting follows the available format options from PHP.
Example Config:
<?php
return [
'cache' => [
'scottboms.mastodon' => [
'type' => 'file',
]
],
'scottboms.mastodon' => [
'username' => 'scottboms',
'instance' => 'mastodon.social',
'dateformat' => 'm-d-Y',
'cache' => true,
'cachettl' => 300 // 5 minutes
'onlymedia' => true,
'panel' => [
'limit' => 6
]
]
]The plugin includes a custom Panel View Button for Kirby 5.x to manually clear the Mastodon cache file which can be added to the site or a page blueprint using the buttons option.
buttons:
mastodoncache: true- Kirby 4.x
- Kirby 5.x
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test before using it in a production environment. If you identify an issue, typo, etc, please create a new issue so I can investigate.
