수정: 블로그 상세 라우트 충돌 제거
This commit is contained in:
@@ -32,10 +32,6 @@ public class BlogController : ControllerBase
|
||||
return Ok(post);
|
||||
}
|
||||
|
||||
[HttpGet("~/blog/{slug}")]
|
||||
public IActionResult RedirectToBlogPage(string slug)
|
||||
=> RedirectPermanent($"/taxbaik/blog/{slug}");
|
||||
|
||||
[HttpGet("admin/all")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetAll()
|
||||
|
||||
@@ -142,60 +142,6 @@ if (!app.Environment.IsDevelopment())
|
||||
app.MapControllers();
|
||||
app.MapHealthChecks("/healthz");
|
||||
app.MapRazorPages();
|
||||
app.MapGet("/blog/{slug}", async (string slug, TaxBaik.Application.Services.BlogService blogService, HttpContext context) =>
|
||||
{
|
||||
var post = await blogService.GetBySlugAsync(slug, context.RequestAborted);
|
||||
if (post == null)
|
||||
return Results.NotFound();
|
||||
|
||||
var baseUrl = $"{context.Request.Scheme}://{context.Request.Host}{context.Request.PathBase}";
|
||||
var canonical = $"{baseUrl}/blog/{post.Slug}";
|
||||
var html = $"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{System.Net.WebUtility.HtmlEncode(post.SeoTitle ?? post.Title)}</title>
|
||||
<meta name="description" content="{System.Net.WebUtility.HtmlEncode(post.SeoDescription ?? string.Empty)}" />
|
||||
<link rel="canonical" href="{canonical}" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>{System.Net.WebUtility.HtmlEncode(post.Title)}</h1>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
return Results.Content(html, "text/html; charset=utf-8");
|
||||
});
|
||||
app.MapGet("/taxbaik/blog/{slug}", async (string slug, TaxBaik.Application.Services.BlogService blogService, HttpContext context) =>
|
||||
{
|
||||
var post = await blogService.GetBySlugAsync(slug, context.RequestAborted);
|
||||
if (post == null)
|
||||
return Results.NotFound();
|
||||
|
||||
var baseUrl = $"{context.Request.Scheme}://{context.Request.Host}{context.Request.PathBase}";
|
||||
var canonical = $"{baseUrl}/blog/{post.Slug}";
|
||||
var html = $"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{System.Net.WebUtility.HtmlEncode(post.SeoTitle ?? post.Title)}</title>
|
||||
<meta name="description" content="{System.Net.WebUtility.HtmlEncode(post.SeoDescription ?? string.Empty)}" />
|
||||
<link rel="canonical" href="{canonical}" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>{System.Net.WebUtility.HtmlEncode(post.Title)}</h1>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
return Results.Content(html, "text/html; charset=utf-8");
|
||||
});
|
||||
app.MapRazorComponents<TaxBaik.Web.Components.Admin.App>().AddInteractiveServerRenderMode();
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user