定制 medienbaecker/kirby-mastodon-replies 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

medienbaecker/kirby-mastodon-replies

最新稳定版本:1.0.0

Composer 安装命令:

composer require medienbaecker/kirby-mastodon-replies

包简介

Fetch and display Mastodon replies on your Kirby pages

README 文档

README

A Kirby CMS plugin that fetches and displays Mastodon replies.

CleanShot 2025-11-03 at 15 16 36@2x

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

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-03