Files
taxbaik/src/TaxBaik.Web/Pages/Sitemap.cshtml.cs
T
kjh2064 89fa51efe2
TaxBaik CI/CD / build-and-deploy (push) Failing after 2m20s
refactor admin UX and stabilize shell
2026-07-09 00:03:33 +09:00

53 lines
1.5 KiB
C#

using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.Services;
namespace TaxBaik.Web.Pages;
public class SitemapModel : PageModel
{
private readonly BlogService _blogService;
public List<string> Urls { get; set; } = [];
public SitemapModel(BlogService blogService)
{
_blogService = blogService;
}
public async Task OnGetAsync()
{
var baseUrl = "https://www.taxbaik.com";
// 정적 페이지 (항상 포함)
Urls.AddRange(new[]
{
$"{baseUrl}",
$"{baseUrl}/about",
$"{baseUrl}/services",
$"{baseUrl}/contact",
$"{baseUrl}/privacy",
$"{baseUrl}/terms",
$"{baseUrl}/blog",
$"{baseUrl}/faq",
$"{baseUrl}/announcement",
$"{baseUrl}/inquiry"
});
// 동적 블로그 포스트 (DB 오류 처리)
try
{
var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 1000, categoryId: null, ct: default);
foreach (var post in posts)
{
Urls.Add($"{baseUrl}/blog/{post.Slug}");
}
}
catch (Exception ex)
{
// DB 연결 실패 등의 경우, 정적 페이지만으로도 sitemap 제공
// 프로덕션에서는 DB가 있으므로 이 경로는 사용되지 않음
System.Diagnostics.Debug.WriteLine($"Sitemap: Blog posts load failed: {ex.Message}");
}
}
}