medienbaecker / kirby-mastodon-replies
Fetch and display Mastodon replies on your Kirby pages
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Type:kirby-plugin
pkg:composer/medienbaecker/kirby-mastodon-replies
Requires
README
A Kirby CMS plugin that fetches and displays Mastodon replies.
Installation
Download
Download and copy this repository to /site/plugins/kirby-mastodon-replies.
Composer
composer require medienbaecker/kirby-mastodon-replies
Usage
1. Add a field to your content
Add a Mastodon post URL to your content file:
Mastodon_url: https://mastodon.social/@username/123456789
If you're using the Panel, add a field to your blueprint:
fields: mastodon_url: label: Mastodon URL type: url
2. Display replies in your template
<?php snippet('mastodon-replies') ?>
I tried to make it easy to override the plugin's markup. You can add snippets to your site for all of these parts:
site/snippets/mastodon-replies.php
site/snippets/mastodon-replies/empty.php
site/snippets/mastodon-replies/error.php
site/snippets/mastodon-replies/heading.php
site/snippets/mastodon-replies/list.php
site/snippets/mastodon-replies/outro.php
site/snippets/mastodon-replies/reply.php
Configuration
return [ 'medienbaecker.kirby-mastodon-replies' => [ 'field' => 'mastodon_url', // Field name for Mastodon post URL 'date.format' => 'd.m.Y H:i:s' // Date format for reply timestamps ] ];
Caching and performance
Consider enabling Kirby's page cache so we're not sending every request to Mastodon's API:
return [ 'cache' => [ 'pages' => true ] ];
On my site I've also added a cronjob that flushes the pages cache regularly. Alternatively you can use MastodonReplies::fetch($url) in an AJAX route and handle caching there.
License
MIT