Skip to content

Create RSS feed of the aggregated blog posts #205 #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions OurUmbraco.Site/Views/Partials/Community/BlogsRss.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@using OurUmbraco.Community.BlogPosts

@inherits OurUmbraco.Our.Models.OurUmbracoTemplatePage
@{
var service = new BlogPostsService();

var items = service.GetCachedBlogPosts(30, 4).ToArray();

if (items.Length == 0)
{
return;
}
}<?xml version="1.0" encoding="UTF-8" ?>
@{
umbraco.library.ChangeContentType("text/xml");
var siteURL = "http://" + Request.Url.Host;
}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="@siteURL/rss" rel="self" type="application/rss+xml" />
<title></title>
@Html.Raw("<link>")@[email protected]("</link>")
<description></description>
<pubDate>@String.Format("{0:ddd, dd MMM yyyy HH:mm:ss} EST", Umbraco.AssignedContentItem.CreateDate)</pubDate>
<lastBuildDate>@String.Format("{0:ddd, dd MMM yyyy HH:mm:ss} EST", DateTime.Now)</lastBuildDate>
<language>en</language>
<generator>Umbraco</generator>

@foreach (var article in items)
{
<item>
<title>@article.Title</title>
@Html.Raw("<link>")@[email protected]@Html.Raw("</link>")
<description>@article.Blog.Title</description>
<pubDate>@String.Format("{0:ddd, dd MMM yyyy} {1:HH:mm:ss} EST", @article.PublishedDate, @article.PublishedDate)</pubDate>
<guid>@siteURL/@article.Link</guid>
</item>
}
</channel>
</rss>