mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-13 11:35:51 +01:00
add meta for noindex,nofollow if policy set
This commit is contained in:
parent
8b6c4a9383
commit
6746a5cbd5
5 changed files with 44 additions and 1 deletions
29
BTCPayServer/Components/RobotsMetaViewComponent.cs
Normal file
29
BTCPayServer/Components/RobotsMetaViewComponent.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Models;
|
||||
using BTCPayServer.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BTCPayServer.Components
|
||||
{
|
||||
public class RobotsMetaViewComponent : ViewComponent
|
||||
{
|
||||
private readonly SettingsRepository _SettingsRepository;
|
||||
|
||||
public RobotsMetaViewComponent(SettingsRepository settingsRepository)
|
||||
{
|
||||
_SettingsRepository = settingsRepository;
|
||||
}
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync()
|
||||
{
|
||||
var policies = await _SettingsRepository.GetSettingAsync<PoliciesSettings>();
|
||||
|
||||
return View(new RobotsMetaViewModel()
|
||||
{
|
||||
DiscourageSearchEngines = policies.DiscourageSearchEngines
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -37,7 +37,6 @@ using BTCPayServer.PaymentRequest;
|
|||
using Meziantou.AspNetCore.BundleTagHelpers;
|
||||
using BTCPayServer.Security;
|
||||
using BTCPayServer.Services.Apps;
|
||||
using Robotify.AspNetCore;
|
||||
|
||||
namespace BTCPayServer.Hosting
|
||||
{
|
||||
|
|
7
BTCPayServer/Models/RobotsMetaViewModel.cs
Normal file
7
BTCPayServer/Models/RobotsMetaViewModel.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace BTCPayServer.Models
|
||||
{
|
||||
public class RobotsMetaViewModel
|
||||
{
|
||||
public bool DiscourageSearchEngines { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
@model BTCPayServer.Models.RobotsMetaViewModel
|
||||
@if (Model.DiscourageSearchEngines)
|
||||
{
|
||||
<META NAME="robots" CONTENT="noindex,nofollow">
|
||||
}
|
|
@ -15,6 +15,9 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<cache expires-after="@TimeSpan.FromMinutes(5)">
|
||||
@await Component.InvokeAsync("RobotsMeta", new { })
|
||||
</cache>
|
||||
|
||||
<title>BTCPay Server</title>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue