Improved SEO by adding noindex header to non-parameterized RSS endpoints
This commit is contained in:
parent
31cec9327f
commit
3bf0f4e6df
|
@ -22,6 +22,9 @@ public class RssController(IOptions<Customization> customizations, ApplicationDb
|
||||||
public async Task<IActionResult> GetRssFeedAsync(string? category = null, Guid? author = null) {
|
public async Task<IActionResult> GetRssFeedAsync(string? category = null, Guid? author = null) {
|
||||||
if (!Features.Value.Rss) return new JsonResult("RSS is disabled") {StatusCode = StatusCodes.Status401Unauthorized};
|
if (!Features.Value.Rss) return new JsonResult("RSS is disabled") {StatusCode = StatusCodes.Status401Unauthorized};
|
||||||
|
|
||||||
|
if (category is not null || author.HasValue)
|
||||||
|
Response.Headers.Append("x-robots-tag", "noindex");
|
||||||
|
|
||||||
var feed = await CreateFeedAll("RssFeed", category, author);
|
var feed = await CreateFeedAll("RssFeed", category, author);
|
||||||
if (feed is null) return NotFound();
|
if (feed is null) return NotFound();
|
||||||
Response.ContentType = "application/atom+xml";
|
Response.ContentType = "application/atom+xml";
|
||||||
|
@ -33,6 +36,9 @@ public class RssController(IOptions<Customization> customizations, ApplicationDb
|
||||||
public async Task<IActionResult> GetAtomFeedAsync(string? category = null, Guid? author = null) {
|
public async Task<IActionResult> GetAtomFeedAsync(string? category = null, Guid? author = null) {
|
||||||
if (!Features.Value.Rss) return new JsonResult("RSS is disabled") {StatusCode = StatusCodes.Status401Unauthorized};
|
if (!Features.Value.Rss) return new JsonResult("RSS is disabled") {StatusCode = StatusCodes.Status401Unauthorized};
|
||||||
|
|
||||||
|
if (category is not null || author.HasValue)
|
||||||
|
Response.Headers.Append("x-robots-tag", "noindex");
|
||||||
|
|
||||||
var feed = await CreateFeedAll("AtomFeed", category, author);
|
var feed = await CreateFeedAll("AtomFeed", category, author);
|
||||||
if (feed is null) return NotFound();
|
if (feed is null) return NotFound();
|
||||||
Response.ContentType = "application/atom+xml";
|
Response.ContentType = "application/atom+xml";
|
||||||
|
|
Loading…
Reference in a new issue