Setting up Kirby Part 1: Microblog

I have added a plugin to my kirby site which changes the slug and the title of any page created with the micropost template. This way, I can create a post in the Micro section and the slug and title will be set to a date-string. This is a good first step of adding a microblog to kirby.

The plugin consists of a class:

class MicroblogPage extends Page
  public static function create(array $props): Page
    $timestamp = time();
    $props['slug'] = "{$timestamp}";

    return parent::create($props);

and a plugin which registers that class and a hook:

Kirby::plugin('inhji/microblog', [
  'pageModels' => [
    'micropost' => MicroblogPage::class
  'hooks' => [
    'page.create:after' => function ($page) {
      if ($page->template()->name() == 'micropost') {
        $timestamp = time();
        $newTitle = date('Y-m-d H:i', $timestamp);

        try {
        } catch(Exception $e) {
          echo $e->getMessage();

API Access