_tommadden
09/08/2024, 7:36 AMSteven (he/him)
09/08/2024, 11:14 AMIContentIndexHandler
in this case as the contentType is already indexed):
using Umbraco.Cms.Core.DeliveryApi;
namespace Umbraco.Docs.Samples;
public class ContentTypesFilter : IFilterHandler
{
private const string ContentTypesSpecifier = "contentTypes:";
private const string FieldName = "contentType";
// Querying
public bool CanHandle(string query)
=> query.StartsWith(ContentTypesSpecifier, StringComparison.OrdinalIgnoreCase);
public FilterOption BuildFilterOption(string filter)
{
var fieldValue = filter.Substring(ContentTypesSpecifier.Length);
// There might be several values for the filter
var values = fieldValue.Split(',');
return new FilterOption
{
FieldName = FieldName,
Values = values,
Operator = FilterOperation.Is
};
}
}
And then the API can be queried as such: /umbraco/delivery/api/v2/content?filter=contentTypes:blog,blogPost
Steven (he/him)
09/08/2024, 11:15 AMBjarne Fyrstenborg
01/09/2025, 8:43 AM