add meta for noindex,nofollow if policy set

This commit is contained in:
Kukks 2019-03-09 14:55:37 +01:00
parent 8b6c4a9383
commit 6746a5cbd5
5 changed files with 44 additions and 1 deletions

View 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
});
}
}
}

View file

@ -37,7 +37,6 @@ using BTCPayServer.PaymentRequest;
using Meziantou.AspNetCore.BundleTagHelpers;
using BTCPayServer.Security;
using BTCPayServer.Services.Apps;
using Robotify.AspNetCore;
namespace BTCPayServer.Hosting
{

View file

@ -0,0 +1,7 @@
namespace BTCPayServer.Models
{
public class RobotsMetaViewModel
{
public bool DiscourageSearchEngines { get; set; }
}
}

View file

@ -0,0 +1,5 @@
@model BTCPayServer.Models.RobotsMetaViewModel
@if (Model.DiscourageSearchEngines)
{
<META NAME="robots" CONTENT="noindex,nofollow">
}

View file

@ -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>