@page "/admin/aboutpageeditor" @layout AdminControlPanelLayout @using Microsoft.Extensions.Options @using MudExRichTextEditor @using MudBlazor @using OpenArchival.Blazor @using OpenArchival.Blazor.AdminPages.Shared @using OpenArchival.Blazor.Config About Page Editor This is the content that will be displayed on the site's about page @((MarkupString)_editorContent) Save @inject ISnackbar Snackbar; @inject IOptions AppOptions; @code { private MudExRichTextEdit _editor = default!; private bool _hasLoaded = false; private string _editorContent = ""; protected override void OnInitialized() { string html = ""; if (File.Exists(AppOptions.Value.AboutPageContentLocation)) { using var reader = new StreamReader(AppOptions.Value.AboutPageContentLocation); html = reader.ReadToEnd(); } else { Snackbar.Add("Homepage file not found, will create one on save!", Severity.Warning); } _editorContent = html; } private async Task OnSaveHomePage(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) { using var writer = new StreamWriter(AppOptions.Value.AboutPageContentLocation); await writer.WriteLineAsync(_editorContent); Snackbar.Add($"Wrote homepage to {AppOptions.Value.AboutPageContentLocation}!", Severity.Success); } }