@page "/admin/homepageeditor" @layout AdminControlPanelLayout @using Microsoft.Extensions.Options @using MudExRichTextEditor @using MudBlazor @using OpenArchival.Blazor @using OpenArchival.Blazor.AdminPages.Shared @using OpenArchival.Blazor.Config Home Page Editor This is the content that will be displayed on the site's home 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.HomepageContentLocation)) { using var reader = new StreamReader(AppOptions.Value.HomepageContentLocation); 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.HomepageContentLocation); await writer.WriteLineAsync(_editorContent); Snackbar.Add($"Wrote homepage to {AppOptions.Value.HomepageContentLocation}!", Severity.Success); } }