diff --git a/src/TaxBaik.Web/Pages/Feed.cshtml b/src/TaxBaik.Web/Pages/Feed.cshtml new file mode 100644 index 0000000..2713d73 --- /dev/null +++ b/src/TaxBaik.Web/Pages/Feed.cshtml @@ -0,0 +1,35 @@ +@page "/feed.xml" +@model TaxBaik.Web.Pages.RssModel +@{ + Response.ContentType = "application/rss+xml; charset=utf-8"; +}@{ + var rssContent = new System.Text.StringBuilder(); + rssContent.AppendLine(""); + rssContent.AppendLine(""); + rssContent.AppendLine(" "); + rssContent.AppendLine(" 백원숙 세무회계 - 블로그"); + rssContent.AppendLine(" https://www.taxbaik.com/taxbaik"); + rssContent.AppendLine(" 세무사 백원숙의 세금, 부동산, 가족자산 전문 블로그"); + rssContent.AppendLine(" ko-kr"); + rssContent.AppendLine($" {Model.LastBuildDate}"); + rssContent.AppendLine(" 60"); + + foreach (var post in Model.Posts) + { + rssContent.AppendLine(" "); + rssContent.AppendLine($" {System.Net.WebUtility.HtmlEncode(post.Title)}"); + rssContent.AppendLine($" https://www.taxbaik.com/taxbaik/blog/{post.Slug}"); + rssContent.AppendLine($" https://www.taxbaik.com/taxbaik/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($" "); + } + rssContent.AppendLine(" "); + } + + rssContent.AppendLine(" "); + rssContent.AppendLine(""); +}@rssContent.ToString() diff --git a/src/TaxBaik.Web/Pages/Rss.cshtml b/src/TaxBaik.Web/Pages/Rss.cshtml new file mode 100644 index 0000000..15cf955 --- /dev/null +++ b/src/TaxBaik.Web/Pages/Rss.cshtml @@ -0,0 +1,35 @@ +@page "/rss.xml" +@model TaxBaik.Web.Pages.RssModel +@{ + Response.ContentType = "application/rss+xml; charset=utf-8"; +}@{ + var rssContent = new System.Text.StringBuilder(); + rssContent.AppendLine(""); + rssContent.AppendLine(""); + rssContent.AppendLine(" "); + rssContent.AppendLine(" 백원숙 세무회계 - 블로그"); + rssContent.AppendLine(" https://www.taxbaik.com/taxbaik"); + rssContent.AppendLine(" 세무사 백원숙의 세금, 부동산, 가족자산 전문 블로그"); + rssContent.AppendLine(" ko-kr"); + rssContent.AppendLine($" {Model.LastBuildDate}"); + rssContent.AppendLine(" 60"); + + foreach (var post in Model.Posts) + { + rssContent.AppendLine(" "); + rssContent.AppendLine($" {System.Net.WebUtility.HtmlEncode(post.Title)}"); + rssContent.AppendLine($" https://www.taxbaik.com/taxbaik/blog/{post.Slug}"); + rssContent.AppendLine($" https://www.taxbaik.com/taxbaik/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($" "); + } + rssContent.AppendLine(" "); + } + + rssContent.AppendLine(" "); + rssContent.AppendLine(""); +}@rssContent.ToString() diff --git a/src/TaxBaik.Web/Pages/Rss.cshtml.cs b/src/TaxBaik.Web/Pages/Rss.cshtml.cs new file mode 100644 index 0000000..9c8b3d3 --- /dev/null +++ b/src/TaxBaik.Web/Pages/Rss.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using TaxBaik.Application.Services; +using TaxBaik.Domain.Entities; + +namespace TaxBaik.Web.Pages; + +public class RssModel : PageModel +{ + private readonly BlogService _blogService; + + public List Posts { get; set; } = []; + public string LastBuildDate { get; set; } = DateTime.UtcNow.ToString("R"); + + public RssModel(BlogService blogService) + { + _blogService = blogService; + } + + public async Task OnGetAsync() + { + // 최근 50개 블로그 포스트 (RSS는 일반적으로 최신 기사만 포함) + var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 50, categoryId: null, ct: default); + Posts = posts.OrderByDescending(p => p.PublishedAt).ToList(); + + LastBuildDate = Posts.FirstOrDefault()?.PublishedAt?.ToString("R") ?? DateTime.UtcNow.ToString("R"); + } +} diff --git a/src/TaxBaik.Web/Pages/_Layout.cshtml b/src/TaxBaik.Web/Pages/_Layout.cshtml index 866261c..5b566fb 100644 --- a/src/TaxBaik.Web/Pages/_Layout.cshtml +++ b/src/TaxBaik.Web/Pages/_Layout.cshtml @@ -28,6 +28,10 @@ + + + + diff --git a/src/TaxBaik.Web/wwwroot/robots.txt b/src/TaxBaik.Web/wwwroot/robots.txt index 025ece5..bd7cb4c 100644 --- a/src/TaxBaik.Web/wwwroot/robots.txt +++ b/src/TaxBaik.Web/wwwroot/robots.txt @@ -30,4 +30,7 @@ Allow: / # Sitemap 위치 Sitemap: https://www.taxbaik.com/taxbaik/sitemap.xml Sitemap: https://taxbaik.com/taxbaik/sitemap.xml -Sitemap: https://www.taxbaik.com/taxbaik/robots.txt + +# RSS 피드 +Sitemap: https://www.taxbaik.com/taxbaik/rss.xml +Sitemap: https://www.taxbaik.com/taxbaik/feed.xml