@using Microsoft.Extensions.Options
@using OpenArchival.Blazor.Config;

@page "/about"

<PageTitle>About</PageTitle>
@if (string.IsNullOrEmpty(_htmlContent))
{
    <p>Loading content...</p> 
}
else
{
    @((MarkupString)_htmlContent)
}

@inject IOptions<ApplicationOptions> AppOptions;
@code {
    private string _htmlContent = $"<h1>HTML file not found for about page. Create one at /admin/aboutpageeditor</h1>";

    protected override async Task OnInitializedAsync()
    {
        try
        {
            using var reader = new StreamReader(AppOptions.Value.AboutPageContentLocation);
            _htmlContent = await reader.ReadToEndAsync(); 
        }
        catch (Exception ex)
        {
            _htmlContent = $"<h1>HTML file not found for homepage. Create one at /admin/aboutpageeditor</h1>";
        }
    }

}

