Skip to content

Instantly share code, notes, and snippets.

@abjerner
Created March 13, 2014 23:10
Show Gist options
  • Save abjerner/9539103 to your computer and use it in GitHub Desktop.
Save abjerner/9539103 to your computer and use it in GitHub Desktop.
Very small amount of code required to create a RSS feed in Umbraco.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Bjerner.Website.Web
@{
Layout = null;
RssFeed feed = new RssFeed {
Title = "Bjerner.dk Blog",
Link = "http://blog.bjerner.dk/",
PubDate = DateTime.Now,
};
foreach (IPublishedContent child in Model.Content.Children.OrderByDescending(x => x.CreateDate).Take(20)) {
feed.Add(new RssItem {
Title = child.Name,
Guid = child.Id.ToString(),
PubDate = child.CreateDate,
Link = child.UrlWithDomain()
});
}
feed.Write();
}
@sociumit
Copy link

Very nice. Of course it is the RssFeed and RssItem classes buried in Bjerner.Website.Web that do all the work. Are you sharing those too?

@abjerner
Copy link
Author

Sure. You can find it here: https://gist.github.com/abjerner/9543768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment