From f5949b1bca9970442edf8e38fcac9a02a35731d1 Mon Sep 17 00:00:00 2001 From: Mia Winter Date: Wed, 18 Sep 2024 13:37:11 +0200 Subject: [PATCH] chore centralized OpenGraph logic --- Wave/Components/OpenGraph.razor | 63 +++++++++++++++++++++++++ Wave/Components/Pages/ArticleView.razor | 21 +-------- Wave/Components/Pages/Home.razor | 22 ++------- Wave/Components/Pages/UserView.razor | 14 +----- 4 files changed, 68 insertions(+), 52 deletions(-) create mode 100644 Wave/Components/OpenGraph.razor diff --git a/Wave/Components/OpenGraph.razor b/Wave/Components/OpenGraph.razor new file mode 100644 index 0000000..80751ea --- /dev/null +++ b/Wave/Components/OpenGraph.razor @@ -0,0 +1,63 @@ +@using Microsoft.Extensions.Options +@using Wave.Data +@using Wave.Utilities + +@inject IOptions Customizations +@inject IOptions Features +@inject NavigationManager Navigation + +@if (Subject is null) { + + + + + @if (!string.IsNullOrWhiteSpace(Customizations.Value.LogoLink)) { + + } else { + + } + @if (!string.IsNullOrWhiteSpace(Customizations.Value.AppDescription)) { + + + } + @if (Features.Value.Rss) { + + + } +} else if (Subject is Article article) { + + + + + + + + @if (article.LastModified.HasValue) { + + } + + @if (Features.Value.Rss) { + + + } + + +} else if (Subject is ApplicationUser user) { + + + + + + + @if (Features.Value.Rss) { + + + } +} + +@code { + [Parameter] + public object? Subject { get; set; } + [Parameter] + public IStringLocalizer? Localizer { get; set; } +} \ No newline at end of file diff --git a/Wave/Components/Pages/ArticleView.razor b/Wave/Components/Pages/ArticleView.razor index 3ac4b70..81ad399 100644 --- a/Wave/Components/Pages/ArticleView.razor +++ b/Wave/Components/Pages/ArticleView.razor @@ -28,26 +28,7 @@ - - - - - - - - - @if (Article.LastModified.HasValue) { - - } - - @if (Features.Value.Rss) { - - - } - - @if (Article is not null) { - - } + } diff --git a/Wave/Components/Pages/Home.razor b/Wave/Components/Pages/Home.razor index f8ed231..e9b44e9 100644 --- a/Wave/Components/Pages/Home.razor +++ b/Wave/Components/Pages/Home.razor @@ -8,28 +8,12 @@ @inject IOptions Customizations @inject IOptions Features @inject NavigationManager Navigation -@inject IDbContextFactory ContextFactory; +@inject IDbContextFactory ContextFactory @inject IStringLocalizer Localizer @inject IMessageDisplay Message - - - - - @if (!string.IsNullOrWhiteSpace(Customizations.Value.LogoLink)) { - - } else { - - } - @if (!string.IsNullOrWhiteSpace(Customizations.Value.AppDescription)) { - - - } - @if (Features.Value.Rss) { - - - } + @if (Page >= TotalPages) { @@ -40,7 +24,7 @@ } -@(Customizations.Value.AppName ?? "Wave") +@(Customizations.Value.AppName)
diff --git a/Wave/Components/Pages/UserView.razor b/Wave/Components/Pages/UserView.razor index 88178be..f200966 100644 --- a/Wave/Components/Pages/UserView.razor +++ b/Wave/Components/Pages/UserView.razor @@ -4,10 +4,8 @@ @using Microsoft.Extensions.Options @using Wave.Utilities -@inject NavigationManager Navigation @inject IDbContextFactory ContextFactory @inject IOptions Customizations -@inject IOptions Features @inject IStringLocalizer Localizer @inject IMessageDisplay Message @@ -16,17 +14,7 @@ - - - - - - - - @if (Features.Value.Rss) { - - - } + } @if (User is null) {