Kirby

Dynamic Kirbytag for headlines?

Another small question, I want to create a Kirbytag which is “dynamically”. In praxis, my customer wants a Kirbytag for h1, h2, h3, h4, h5, h6. Of course, I can create for each a own Kirbytag, but on changes I have to do the changes on 6 Kirbytags.

Best will be, that always the same code is used, no matter if he use (h1: TEST) or (h2: TEST) … only change the HTML Tag.

Is there something like this: (x should be 1,2,3 …)

'h' . $x => [
    'attr' => [],
    'html' => function ($tag) {
      
      return '<h' . $x . '>TEST'</h' . $x . '>;
      
    }
  ],

You can achieve that with a Kirbytag hook instead of a Kirbytag. But why a Kirbytag for a headline, markdown syntax is a lot easier than a tag?

I have also argumented the same. But client want to have different looks for headlines, different colors, sizes and more. To much to handle with default CSS cause it has no system.

I think I will do it with 6 Kirbytags :wink:

I’d go with the hook instead of basically repeating the same code over and over again…