This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
@{
|
@{
|
||||||
Layout = null;
|
Layout = null;
|
||||||
Response.ContentType = "application/rss+xml; charset=utf-8";
|
Response.ContentType = "application/rss+xml; charset=utf-8";
|
||||||
}@{
|
|
||||||
var rssContent = new System.Text.StringBuilder();
|
var rssContent = new System.Text.StringBuilder();
|
||||||
rssContent.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
rssContent.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
rssContent.AppendLine("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">");
|
rssContent.AppendLine("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">");
|
||||||
@@ -11,27 +10,39 @@
|
|||||||
rssContent.AppendLine(" <title>백원숙 세무회계 - 블로그</title>");
|
rssContent.AppendLine(" <title>백원숙 세무회계 - 블로그</title>");
|
||||||
rssContent.AppendLine(" <link>https://www.taxbaik.com</link>");
|
rssContent.AppendLine(" <link>https://www.taxbaik.com</link>");
|
||||||
rssContent.AppendLine(" <description>세무사 백원숙의 세금, 부동산, 가족자산 전문 블로그</description>");
|
rssContent.AppendLine(" <description>세무사 백원숙의 세금, 부동산, 가족자산 전문 블로그</description>");
|
||||||
rssContent.AppendLine(" <language>ko-kr</language>");
|
rssContent.AppendLine(" <language>ko-KR</language>");
|
||||||
rssContent.AppendLine($" <lastBuildDate>{Model.LastBuildDate}</lastBuildDate>");
|
rssContent.AppendLine($" <lastBuildDate>{Model.LastBuildDate}</lastBuildDate>");
|
||||||
rssContent.AppendLine(" <atom:link href=\"https://www.taxbaik.com/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />");
|
rssContent.AppendLine(" <atom:link href=\"https://www.taxbaik.com/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />");
|
||||||
rssContent.AppendLine(" <ttl>60</ttl>");
|
rssContent.AppendLine(" <ttl>60</ttl>");
|
||||||
|
|
||||||
foreach (var post in Model.Posts)
|
foreach (var post in Model.Posts)
|
||||||
{
|
{
|
||||||
|
var postUrl = $"https://www.taxbaik.com/blog/{Uri.EscapeDataString(post.Slug)}";
|
||||||
|
var description = post.Content?.Substring(0, Math.Min(200, post.Content?.Length ?? 0)) ?? string.Empty;
|
||||||
|
var safeDescription = description.Replace("]]>", "]]]]><![CDATA[>");
|
||||||
|
var safeContent = post.Content?.Replace("]]>", "]]]]><![CDATA[>");
|
||||||
|
|
||||||
rssContent.AppendLine(" <item>");
|
rssContent.AppendLine(" <item>");
|
||||||
rssContent.AppendLine($" <title>{System.Net.WebUtility.HtmlEncode(post.Title)}</title>");
|
rssContent.AppendLine($" <title>{System.Net.WebUtility.HtmlEncode(post.Title)}</title>");
|
||||||
rssContent.AppendLine($" <link>https://www.taxbaik.com/blog/{post.Slug}</link>");
|
rssContent.AppendLine($" <link>{postUrl}</link>");
|
||||||
rssContent.AppendLine($" <guid isPermaLink=\"true\">https://www.taxbaik.com/blog/{post.Slug}</guid>");
|
rssContent.AppendLine($" <guid isPermaLink=\"true\">{postUrl}</guid>");
|
||||||
rssContent.AppendLine($" <pubDate>{post.PublishedAt?.ToString("R")}</pubDate>");
|
|
||||||
var desc = post.Content?.Substring(0, Math.Min(200, post.Content?.Length ?? 0)) ?? "";
|
if (post.PublishedAt is not null)
|
||||||
rssContent.AppendLine($" <description>{System.Net.WebUtility.HtmlEncode(desc)}</description>");
|
|
||||||
if (!string.IsNullOrEmpty(post.Content))
|
|
||||||
{
|
{
|
||||||
rssContent.AppendLine($" <content:encoded><![CDATA[{post.Content.Replace("]]>", "]]]]><![CDATA[>")}]]></content:encoded>");
|
rssContent.AppendLine($" <pubDate>{post.PublishedAt.Value.ToUniversalTime():R}</pubDate>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rssContent.AppendLine($" <description><![CDATA[{safeDescription}]]></description>");
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(safeContent))
|
||||||
|
{
|
||||||
|
rssContent.AppendLine($" <content:encoded><![CDATA[{safeContent}]]></content:encoded>");
|
||||||
|
}
|
||||||
|
|
||||||
rssContent.AppendLine(" </item>");
|
rssContent.AppendLine(" </item>");
|
||||||
}
|
}
|
||||||
|
|
||||||
rssContent.AppendLine(" </channel>");
|
rssContent.AppendLine(" </channel>");
|
||||||
rssContent.AppendLine("</rss>");
|
rssContent.AppendLine("</rss>");
|
||||||
}@Html.Raw(rssContent.ToString())
|
}
|
||||||
|
@Html.Raw(rssContent.ToString())
|
||||||
|
|||||||
Reference in New Issue
Block a user