MattByName / Pico-RssMaker

Very basic RSS plugin for Pico. Generates RSS feed of all pages with a date. Based on old pico_rss plugin and PicoXMLSitemap plugin.
MIT License
7 stars 5 forks source link

Question: How to add RSS item sub-element from page-meta-data? #6

Open new-on-github opened 5 months ago

new-on-github commented 5 months ago

I use Pico-RssMaker and like it.

it seems possible to add a image to a rss-item as sub-element: https://www.rssboard.org/rss-specification#ltenclosuregtSubelementOfLtitemgt I want to add a image form the meta-tag "image" from my pico-md-yaml-header.

How to do this in php. I tried some versions like:

$rss .= '<enclosure>'; $rss .= $page['image']; $rss .= '</enclosure>';

But this is not working.

My question now is: How to access the page-meta-data via php?

It would be really nice if you could help me with this question.

Btw thanks a lot for the Pico-RssMaker!

MattByName commented 5 months ago

hi thanks for raising an issue. I can take a look this weekend.

new-on-github commented 5 months ago

Thanks a lot for your very quick reply. This would be amazing!

I also tried:

$rss .= '<enclosure>';
$rss .= $meta['image'];
$rss .= '</enclosure>';

without success.

MattByName commented 5 months ago

Unfortunately, I've had trouble getting Pico to run at all- I don't actually use it anymore. I think what you'd need is to make sure image is a url to the image, and then add either:

$rss .= '<enclosure url="';
$rss .= $meta['image'];
$rss .= '"/>';

or

$rss .= '<enclosure url="';
$rss .= $page.meta['image'];
$rss .= '"/>';

or

$rss .= '<enclosure url="';
$rss .= $page['image'];
$rss .= '"/>';

If you can get it to work, do let me know and I can update the plugin :)

new-on-github commented 5 months ago

I tried it all. But the rss-file gives always a empty enclosure-item back. <enclosure url=""/> I think the problem is, that $page['image']; does not reference to the meta header item image: %assets_url%/.... To get the time with pico-rssmaker you also not call $page['date']; but $page['time'];. Maybe there is a function which gets the meta-data and puts it somewhere else...

MattByName commented 5 months ago

Perhaps image is a keyword? Could you try renaming it to rssimage?

new-on-github commented 5 months ago

Thanks for this idea. But this seems not to be the problem. I will have to think about it or ask somewhere else. Thanks a lot for your help to this point!

new-on-github commented 5 months ago

With some help from the pros https://github.com/picocms/Pico/issues/698 it works now with the following code:

$rss .= '<enclosure url="';
$rss .= str_replace('%assets_url%', $this->baseURL."assets", $page['meta']['image']);
$rss .= '"/>';

Thanks for your help!