@using Microsoft.EntityFrameworkCore @using Microsoft.Extensions.Caching.Memory @using Microsoft.Extensions.Options @using OpenArchival.Blazor.Components.CustomComponents @using OpenArchival.Blazor.Config; @using OpenArchival.Blazor.Blog @using OpenArchival.Blazor.ArchiveDisplay @page "/" Home @if (_homePageConfig is null) {

Loading content...

} else { @if (_homePageConfig.HomePageBanner is not null) { } else { } @if (!string.IsNullOrEmpty(_homePageConfig.Content)) { // Uses a custom CSS class to force the content to the width of the page regardless of what is in it // ql-editor class tells the quill css that it should apply its classes in this div. Quill is used by the rich text editor this // project uses
@((MarkupString)_homePageConfig.Content)
} @if (_homePageConfig.SliderEntries != null) { @foreach (var sliderEntry in _homePageConfig.SliderEntries) { } } } @inject IOptions AppOptions; @inject IMemoryCache MemoryCache; @inject IDbContextFactory ContextFactory; @code { private string _htmlContent = $"

HTML file not found for homepage. Create one at /admin/homepageeditor

"; private HomePageConfiguration? _homePageConfig = null; protected override async Task OnInitializedAsync() { _homePageConfig = await MemoryCache.GetOrCreateAsync(OpenArchivalConstants.HomePageConfigurationCacheKey, async entry => { await using var context = await ContextFactory.CreateDbContextAsync(); HomePageConfiguration? config = await context.HomePageConfiguration .Include(conf=>conf.HomePageBanner) .Include(conf=>conf.SliderEntries) .ThenInclude(se => se.FilterTags) .FirstOrDefaultAsync(); if (config is null) { return new HomePageConfiguration() { Content = "Failed to load HomePageConfiguration from the database!" }; } return config; }); StateHasChanged(); } }