diff --git a/src/TaxBaik.Web/Pages/Rss.cshtml b/src/TaxBaik.Web/Pages/Rss.cshtml index 9393831..d230c45 100644 --- a/src/TaxBaik.Web/Pages/Rss.cshtml +++ b/src/TaxBaik.Web/Pages/Rss.cshtml @@ -3,7 +3,6 @@ @{ Layout = null; Response.ContentType = "application/rss+xml; charset=utf-8"; -}@{ var rssContent = new System.Text.StringBuilder(); rssContent.AppendLine(""); rssContent.AppendLine(""); @@ -11,27 +10,39 @@ rssContent.AppendLine(" 백원숙 세무회계 - 블로그"); rssContent.AppendLine(" https://www.taxbaik.com"); rssContent.AppendLine(" 세무사 백원숙의 세금, 부동산, 가족자산 전문 블로그"); - rssContent.AppendLine(" ko-kr"); + rssContent.AppendLine(" ko-KR"); rssContent.AppendLine($" {Model.LastBuildDate}"); rssContent.AppendLine(" "); rssContent.AppendLine(" 60"); 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("]]>", "]]]]>"); + var safeContent = post.Content?.Replace("]]>", "]]]]>"); + rssContent.AppendLine(" "); rssContent.AppendLine($" {System.Net.WebUtility.HtmlEncode(post.Title)}"); - rssContent.AppendLine($" https://www.taxbaik.com/blog/{post.Slug}"); - rssContent.AppendLine($" https://www.taxbaik.com/blog/{post.Slug}"); - rssContent.AppendLine($" {post.PublishedAt?.ToString("R")}"); - var desc = post.Content?.Substring(0, Math.Min(200, post.Content?.Length ?? 0)) ?? ""; - rssContent.AppendLine($" {System.Net.WebUtility.HtmlEncode(desc)}"); - if (!string.IsNullOrEmpty(post.Content)) + rssContent.AppendLine($" {postUrl}"); + rssContent.AppendLine($" {postUrl}"); + + if (post.PublishedAt is not null) { - rssContent.AppendLine($" ", "]]]]>")}]]>"); + rssContent.AppendLine($" {post.PublishedAt.Value.ToUniversalTime():R}"); } + + rssContent.AppendLine($" "); + + if (!string.IsNullOrWhiteSpace(safeContent)) + { + rssContent.AppendLine($" "); + } + rssContent.AppendLine(" "); } rssContent.AppendLine(" "); rssContent.AppendLine(""); -}@Html.Raw(rssContent.ToString()) +} +@Html.Raw(rssContent.ToString())