mirror of
https://github.com/danpros/htmly.git
synced 2026-04-22 05:26:22 +05:30
Improve RSS feed
Improve RSS feed, adding sitemap and markup.
This commit is contained in:
parent
0f53d0de69
commit
bd66a69ad5
5 changed files with 39 additions and 5 deletions
|
|
@ -30,3 +30,5 @@ Disallow: /composer.lock
|
|||
Disallow: /composer.phar
|
||||
# Paths
|
||||
Disallow: /search/
|
||||
|
||||
Sitemap: /feed/sitemap
|
||||
|
|
@ -270,6 +270,14 @@ get('/feed/rss',function(){
|
|||
echo generate_rss(get_posts(null, 1, config('rss.count')));
|
||||
});
|
||||
|
||||
// Show the RSS feed for sitemap
|
||||
get('/feed/sitemap',function(){
|
||||
|
||||
header('Content-Type: application/rss+xml');
|
||||
|
||||
// Generate RSS feed for all blog posts
|
||||
echo generate_sitemap(get_posts(null, null, null));
|
||||
});
|
||||
|
||||
// If we get here, it means that
|
||||
// nothing has been matched above
|
||||
|
|
|
|||
|
|
@ -935,12 +935,36 @@ function generate_rss($posts){
|
|||
->appendTo($feed);
|
||||
|
||||
foreach($posts as $p){
|
||||
|
||||
$item = new Item();
|
||||
$item
|
||||
->title($p->title)
|
||||
->pubDate($p->date)
|
||||
->description($p->body)
|
||||
->url($p->url)
|
||||
->category($p->tag, $p->tagurl)
|
||||
->appendTo($channel);
|
||||
}
|
||||
|
||||
echo $feed;
|
||||
}
|
||||
|
||||
// Turn an array of posts into an RSS feed for sitemap
|
||||
function generate_sitemap($posts){
|
||||
|
||||
$feed = new Feed();
|
||||
$channel = new Channel();
|
||||
|
||||
$channel
|
||||
->title(config('blog.title'))
|
||||
->description(config('blog.description'))
|
||||
->url(site_url())
|
||||
->appendTo($feed);
|
||||
|
||||
foreach($posts as $p){
|
||||
$item = new Item();
|
||||
$item
|
||||
->title($p->title)
|
||||
->url($p->url)
|
||||
->appendTo($channel);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body class="<?php echo $bodyclass; ?>">
|
||||
<div itemscope="itemscope" itemtype="http://schema.org/Blog" class="hide">
|
||||
<body class="<?php echo $bodyclass; ?>" itemscope="itemscope" itemtype="http://schema.org/Blog">
|
||||
<div class="hide">
|
||||
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
|
||||
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body class="<?php echo $bodyclass; ?>">
|
||||
<div itemscope="itemscope" itemtype="http://schema.org/Blog" class="hide">
|
||||
<body class="<?php echo $bodyclass; ?>" itemscope="itemscope" itemtype="http://schema.org/Blog">
|
||||
<div class="hide">
|
||||
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
|
||||
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue