Closed bata03 closed 6 months ago
I've created a custom ContentFilter as described in the documentation:
public class SitemapContentFilter : ContentFilter { public SitemapContentFilter(TemplateResolver templateResolver, ILogger<ContentFilter> logger) : base(templateResolver, logger) { } public override bool ShouldExcludeContent(IContent content) { if (base.ShouldExcludeContent(content)) { return true; } bool excludeContent = false; if (content is BasePageData) { var basePageData = content as BasePageData; excludeContent = basePageData?.DisableIndexing ?? false; } if (content is DocumentFile) { var documentFile = content as DocumentFile; excludeContent = documentFile?.DisableIndexing ?? false; } return excludeContent; } }
And I've registered it for DI:
services.AddTransient<IContentFilter, SitemapContentFilter>();
However, the custom filter is never called. What am not seeing? :)
Sorry, my bad. I called services.AddTransient<IContentFilter, SitemapContentFilter>() before calling services.AddSitemaps() which meant that my ContentFilter DI-entry got overwritten.
I've created a custom ContentFilter as described in the documentation:
And I've registered it for DI:
services.AddTransient<IContentFilter, SitemapContentFilter>();
However, the custom filter is never called. What am not seeing? :)