Generate an RSS feed based on block content

Hey yall,

I’m trying to get an RSS feed to work for my blog. Nothing unusual I’d imagine. I’m using the kirby3-feed plugin. The only issue is: I’m using Blocks to layout and store the content.

That results in RSS which looks like this

…This is a heading
"},"id":"32ecb215-f90a-49bb-8930-b0c94371529e","isHidden":false,"type":"text"},{"content":{"text":"more text …

which is obviously not my desired outcome …

Now, I’m not too well versed in PHP, but I think the code I wrote would permanently modify the pages.

            function renderText($page)  {
				$text = $page->text();
				$html = $text->toBlocks();

				// Overwrite $page->text() with $html
				$page->update(["text"->$html]);

				return $page;
            }
            // using a closure allows for better performance on a cache hit
            return feed(fn() => page('neuigkeiten')->children()->listed()->flip()->limit(10)->map('renderText'), $options);

So now I’m wondering: I can’t be the first person with this goal, right? What would be the proper way to do this?

Thanks!

I’d replace the snippet (kirby3-feed/snippets/feed/rss.php at master · bnomei/kirby3-feed · GitHub), that is, make a copy of it in /site/snippets/ and replace this line

      <description><![CDATA[<?= $item->{$textfield}()->kirbytext() ?>]]></description>

with

<description><![CDATA[<?= $item->{$textfield}()->toBlocks() ?>]]></description>