29 lines
739 B
C#
29 lines
739 B
C#
using Elternbeirat.Web.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace Elternbeirat.Web.Features.Pages;
|
|
|
|
public partial class ContentPage
|
|
{
|
|
[Parameter]
|
|
public string Slug { get; set; } = "";
|
|
|
|
private Page? _page;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
_page = PageService.Find(Slug);
|
|
|
|
// Unknown slug -> 404, so UseStatusCodePagesWithReExecute serves the
|
|
// /not-found page instead of an empty 200 response.
|
|
if (_page is null && HttpContext is not null)
|
|
{
|
|
HttpContext.Response.StatusCode = StatusCodes.Status404NotFound;
|
|
}
|
|
}
|
|
|
|
[CascadingParameter]
|
|
private HttpContext? HttpContext { get; set; }
|
|
}
|