Added alternatve links for RSS to pages containing articles

This commit is contained in:
Mia Rose Winter 2024-02-12 14:21:43 +01:00
parent 94666fb26d
commit aa5b7f04fc
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
3 changed files with 20 additions and 0 deletions

View file

@ -9,6 +9,7 @@
@inject IDbContextFactory<ApplicationDbContext> ContextFactory @inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject NavigationManager Navigation @inject NavigationManager Navigation
@inject IOptions<Customization> Customizations @inject IOptions<Customization> Customizations
@inject IOptions<Features> Features
@inject IStringLocalizer<ArticleView> Localizer @inject IStringLocalizer<ArticleView> Localizer
<PageTitle>@(TitlePrefix + (Article?.Title ?? Localizer["NotFound_Title"]))</PageTitle> <PageTitle>@(TitlePrefix + (Article?.Title ?? Localizer["NotFound_Title"]))</PageTitle>
@ -30,6 +31,10 @@
<meta property="og:article:modified_time" content="@Article.LastModified.Value.ToString("u")"> <meta property="og:article:modified_time" content="@Article.LastModified.Value.ToString("u")">
} }
<meta property="og:site_name" content="@Customizations.Value.AppName"> <meta property="og:site_name" content="@Customizations.Value.AppName">
@if (Features.Value.Rss) {
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName" href="/rss/rss.xml">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName" href="/rss/atom.xml">
}
</HeadContent> </HeadContent>
} }

View file

@ -2,10 +2,20 @@
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@using Wave.Data @using Wave.Data
@using System.Net @using System.Net
@using Microsoft.Extensions.Options
@inject IDbContextFactory<ApplicationDbContext> ContextFactory @inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IOptions<Customization> Customizations
@inject IOptions<Features> Features
@inject IStringLocalizer<CategoryView> Localizer @inject IStringLocalizer<CategoryView> Localizer
<HeadContent>
@if (Features.Value.Rss && Category is not null) {
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName | @Category.Name" href="/rss/rss.xml?category=@WebUtility.UrlEncode(Category.Name)">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName | @Category.Name" href="/rss/atom.xml?category=@WebUtility.UrlEncode(Category.Name)">
}
</HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"] + " | " + (Category?.Name ?? "Not Found"))</PageTitle> <PageTitle>@(TitlePrefix + Localizer["Title"] + " | " + (Category?.Name ?? "Not Found"))</PageTitle>
@if (Category is null) { @if (Category is null) {

View file

@ -8,6 +8,7 @@
@rendermode InteractiveServer @rendermode InteractiveServer
@attribute [StreamRendering] @attribute [StreamRendering]
@inject IOptions<Customization> Customizations @inject IOptions<Customization> Customizations
@inject IOptions<Features> Features
@inject NavigationManager Navigation @inject NavigationManager Navigation
@inject IDbContextFactory<ApplicationDbContext> ContextFactory; @inject IDbContextFactory<ApplicationDbContext> ContextFactory;
@inject IStringLocalizer<Home> Localizer @inject IStringLocalizer<Home> Localizer
@ -26,6 +27,10 @@
<meta property="description" content="@Customizations.Value.AppDescription"> <meta property="description" content="@Customizations.Value.AppDescription">
<meta property="og:description" content="@Customizations.Value.AppDescription"> <meta property="og:description" content="@Customizations.Value.AppDescription">
} }
@if (Features.Value.Rss) {
<link rel="alternate" type="application/rss+xml" title="RSS Feed on @Customizations.Value.AppName" href="/rss/rss.xml">
<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed on @Customizations.Value.AppName" href="/rss/atom.xml">
}
</HeadContent> </HeadContent>
<PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle> <PageTitle>@(TitlePrefix + Localizer["Title"])</PageTitle>