✨ Rewrite for Kirby
This commit is contained in:
parent
07201d05de
commit
f854d60108
116 changed files with 4156 additions and 8875 deletions
31
site/templates/blog.rss.php
Normal file
31
site/templates/blog.rss.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
$feed = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"></rss>');
|
||||
|
||||
$feed->channel->title = $site->title()->toString();
|
||||
$feed->channel->description = $site->description()->toString();
|
||||
$feed->channel->link = url();
|
||||
$feed->channel->language = 'en-us';
|
||||
$feed->channel->lastBuildDate = date(DATE_RSS);
|
||||
$feed->channel->generator = 'Kirby';
|
||||
|
||||
$atomLink = $feed->channel->addChild('atom:link', null, 'atom');
|
||||
$atomLink->addAttribute('href', url('/feed'));
|
||||
$atomLink->addAttribute('rel', 'self');
|
||||
$atomLink->addAttribute('type', 'application/rss+xml');
|
||||
|
||||
$articles = $page->children()->template('article')->sortBy('date', 'desc')->limit(10);
|
||||
|
||||
foreach ($articles as $article) {
|
||||
$xmlArticle = $feed->channel->addChild('item');
|
||||
$xmlArticle->title = $article->title()->toString();
|
||||
$xmlArticle->link = url($article->url());
|
||||
$xmlArticle->description = Escape::xml($article->text()->kirbytext());
|
||||
$xmlArticle->pubDate = $article->date()->toDate(DATE_RSS);
|
||||
$xmlArticle->guid = url($article->url());
|
||||
}
|
||||
|
||||
$kirby->response()->type('application/rss+xml');
|
||||
|
||||
echo $feed->asXML();
|
Loading…
Add table
Add a link
Reference in a new issue