Files
Umbraco-CMS/src/Umbraco.Cms.Api.Delivery/Indexing/Sorts/CreateDateSortIndexer.cs
Kenn Jacobsen fc3f342906 Add sort handlers for create and update date (#14178)
* Add sort handlers for create and update date

* Make things sealed

* Update the field names

---------

Co-authored-by: Elitsa <elm@umbraco.dk>
2023-04-28 11:14:50 +02:00

16 lines
553 B
C#

using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Core.Models;
namespace Umbraco.Cms.Api.Delivery.Indexing.Sorts;
public sealed class CreateDateSortIndexer : IContentIndexHandler
{
internal const string FieldName = "createDate";
public IEnumerable<IndexFieldValue> GetFieldValues(IContent content)
=> new[] { new IndexFieldValue { FieldName = FieldName, Value = content.CreateDate } };
public IEnumerable<IndexField> GetFields()
=> new[] { new IndexField { FieldName = FieldName, FieldType = FieldType.Date } };
}