Skip to content

Commit 69a659e

Browse files
committed
Added support for adding an "atom:link" element (now by default) to the channel element
1 parent 5fa0d41 commit 69a659e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Skybrud.Umbraco.RssUtils/RssFeed.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ public List<RssItem> Items {
7070
set { _items = value ?? new List<RssItem>(); }
7171
}
7272

73+
public bool IncludeAtomLink { get; set; }
74+
7375
#endregion
7476

7577
#region Constructor
7678

7779
public RssFeed() {
7880
Version = "2.0";
81+
IncludeAtomLink = true;
7982
}
8083

8184
/// <summary>
@@ -214,6 +217,18 @@ public XDocument ToXDocument() {
214217
xRss.Add(new XAttribute("version", Version));
215218
}
216219

220+
// Append "atom:link" to the channel (if enabled)
221+
if (IncludeAtomLink) {
222+
XNamespace atom = "http://www.w3.org/2005/Atom";
223+
xRss.Add(new XAttribute(XNamespace.Xmlns + "atom", "http://www.w3.org/2005/Atom"));
224+
xChannel.Add(new XElement(
225+
atom + "link",
226+
new XAttribute("href", Link ?? ""),
227+
new XAttribute("rel", "self"),
228+
new XAttribute("type", "application/rss+xml")
229+
));
230+
}
231+
217232
// Add the items to the channel
218233
xChannel.Add(from item in Items orderby item.PubDate descending select item.ToXElement());
219234

0 commit comments

Comments
 (0)