41 lines
1.8 KiB
Plaintext
41 lines
1.8 KiB
Plaintext
@page "/rss.xml"
|
|
@model TaxBaik.Web.Pages.RssModel
|
|
@{
|
|
Layout = null;
|
|
Response.ContentType = "application/rss+xml; charset=utf-8";
|
|
var rssContent = new System.Text.StringBuilder();
|
|
rssContent.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
rssContent.AppendLine("<rss version=\"2.0\">");
|
|
rssContent.AppendLine(" <channel>");
|
|
rssContent.AppendLine(" <title>백원숙 세무회계 - 블로그</title>");
|
|
rssContent.AppendLine(" <link>https://www.taxbaik.com</link>");
|
|
rssContent.AppendLine(" <description>세무사 백원숙의 세금, 부동산, 가족자산 전문 블로그</description>");
|
|
rssContent.AppendLine(" <language>ko-KR</language>");
|
|
rssContent.AppendLine($" <lastBuildDate>{Model.LastBuildDate}</lastBuildDate>");
|
|
rssContent.AppendLine(" <ttl>60</ttl>");
|
|
|
|
foreach (var item in Model.Items)
|
|
{
|
|
var itemUrl = item.Link;
|
|
var fullDescription = item.Description ?? string.Empty;
|
|
var safeDescription = fullDescription.Replace("]]>", "]]]]><![CDATA[>");
|
|
|
|
rssContent.AppendLine(" <item>");
|
|
rssContent.AppendLine($" <title>{System.Net.WebUtility.HtmlEncode(item.Title)}</title>");
|
|
rssContent.AppendLine($" <link>{itemUrl}</link>");
|
|
rssContent.AppendLine($" <guid isPermaLink=\"true\">{item.Guid}</guid>");
|
|
|
|
if (item.PublishedAt is not null)
|
|
{
|
|
rssContent.AppendLine($" <pubDate>{item.PublishedAt.Value.ToUniversalTime():R}</pubDate>");
|
|
}
|
|
|
|
rssContent.AppendLine($" <description><![CDATA[{safeDescription}]]></description>");
|
|
rssContent.AppendLine(" </item>");
|
|
}
|
|
|
|
rssContent.AppendLine(" </channel>");
|
|
rssContent.AppendLine("</rss>");
|
|
}
|
|
@Html.Raw(rssContent.ToString())
|