fix: correct BlogService GetPublishedPagedAsync parameter order
TaxBaik CI/CD / build-and-deploy (push) Failing after 1m25s
TaxBaik CI/CD / build-and-deploy (push) Failing after 1m25s
Use named parameters for clarity: - categoryId: null - ct: ct (cancellation token) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using FastEndpoints;
|
||||
using TaxBaik.Application.Services;
|
||||
|
||||
namespace TaxBaik.Web.Endpoints;
|
||||
|
||||
/// <summary>
|
||||
/// GET /api/sitemap.xml - 동적 사이트맵 생성
|
||||
/// 블로그 포스트, FAQ, 공지사항 포함
|
||||
/// </summary>
|
||||
public class SitemapEndpoint : EndpointWithoutRequest<string>
|
||||
{
|
||||
private readonly BlogService _blogService;
|
||||
|
||||
public SitemapEndpoint(BlogService blogService)
|
||||
{
|
||||
_blogService = blogService;
|
||||
}
|
||||
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/sitemap.xml");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task<string> ExecuteAsync(CancellationToken ct)
|
||||
{
|
||||
var baseUrl = "https://www.taxbaik.com/taxbaik";
|
||||
var urls = new List<string>
|
||||
{
|
||||
// 정적 페이지
|
||||
$"{baseUrl}",
|
||||
$"{baseUrl}/about",
|
||||
$"{baseUrl}/services",
|
||||
$"{baseUrl}/contact",
|
||||
$"{baseUrl}/privacy",
|
||||
$"{baseUrl}/terms",
|
||||
$"{baseUrl}/blog",
|
||||
$"{baseUrl}/faq",
|
||||
$"{baseUrl}/announcement",
|
||||
$"{baseUrl}/inquiry"
|
||||
};
|
||||
|
||||
// 동적 블로그 포스트
|
||||
var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 1000, categoryId: null, ct: ct);
|
||||
foreach (var post in posts)
|
||||
{
|
||||
urls.Add($"{baseUrl}/blog/{post.Slug}");
|
||||
}
|
||||
|
||||
// XML 생성
|
||||
var now = DateTime.UtcNow.ToString("yyyy-MM-dd");
|
||||
var urlEntries = string.Join("\n", urls.Select(url =>
|
||||
$" <url>\n <loc>{System.Net.WebUtility.HtmlEncode(url)}</loc>\n <lastmod>{now}</lastmod>\n </url>"));
|
||||
|
||||
var xml = $"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n{urlEntries}\n</urlset>";
|
||||
|
||||
// XML Content-Type 설정
|
||||
HttpContext.Response.ContentType = "application/xml; charset=utf-8";
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@page "/sitemap.xml"
|
||||
@model TaxBaik.Web.Pages.SitemapModel
|
||||
@{
|
||||
Response.ContentType = "application/xml";
|
||||
}<?xml version="1.0" encoding="utf-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
@foreach (var url in Model.Urls)
|
||||
{
|
||||
<url>
|
||||
<loc>@url</loc>
|
||||
<lastmod>@DateTime.UtcNow:yyyy-MM-dd</lastmod>
|
||||
</url>
|
||||
}
|
||||
</urlset>
|
||||
@@ -1,49 +0,0 @@
|
||||
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 = $"{Request.Scheme}://{Request.Host.Value}/taxbaik";
|
||||
|
||||
// 정적 페이지 (공개 콘텐츠만)
|
||||
Urls.AddRange(new[]
|
||||
{
|
||||
// 홈페이지
|
||||
$"{baseUrl}",
|
||||
$"{baseUrl}/about",
|
||||
$"{baseUrl}/services",
|
||||
$"{baseUrl}/contact",
|
||||
$"{baseUrl}/privacy",
|
||||
$"{baseUrl}/terms",
|
||||
|
||||
// 공개 콘텐츠
|
||||
$"{baseUrl}/blog",
|
||||
$"{baseUrl}/faq",
|
||||
$"{baseUrl}/announcement",
|
||||
$"{baseUrl}/inquiry"
|
||||
|
||||
// 제외: /admin (관리자), /portal (고객 포탈)
|
||||
// robots.txt에서도 disallow
|
||||
});
|
||||
|
||||
// 동적 페이지: 블로그 포스트
|
||||
var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 1000);
|
||||
foreach (var post in posts)
|
||||
{
|
||||
Urls.Add($"{baseUrl}/blog/{post.Slug}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user