Blog filter and sort example

The blog post filter and sort example is used to introduce the features of the filter API. The blog post itself includes filter and sort traits. If you've already registered the rest of the schemas from the blog post page, you don't need to register the author, image, text and video schemas.

Pre-requisites

See the using the content type schema examples page for details of how to choose and register these schemas from the schema examples in Dynamic Content.

If you haven't already registered the blog author, blog image, blog video and blog text schemas you should register the schemas shown on the blog page.

How to use

Once you've registered the schemas from this page, you should be able to follow the examples on the filter API page.

Blog post filter and sort

This is the main blog post content type schema. It includes a trait:filterable and trait:sortable as well as links to example-author, example-text, example-image and example-video. Note that many of the properties are required.

{
   "$schema":"http://json-schema.org/draft-07/schema#",
   "$id":"https://schema-examples.com/blog-post-filter-and-sort",
   "title":"Blog post",
   "description":"A blog post that can be filtered and sorted",
   "$comment":"Docs: https://amplience.com/docs/development/schema-examples/filter/filter-blog.html",
   "allOf":[
      {
         "$ref":"http://bigcontent.io/cms/schema/v1/core#/definitions/content"
      }
   ],
   "type":"object",
   "properties":{
      "title":{
         "title":"Title",
         "description":"Used for heading and SEO title tag",
         "type":"string",
         "minLength":1,
         "maxLength":150
      },
      "date":{
         "title":"Creation date",
         "description":"Creation date (YYYY-MM-DD)",
         "type":"string",
         "maxLength":10,
         "minLength":10
      },
      "ranking":{
         "title":"Ranking",
         "description":"used for sorting blog posts",
         "type":"number",
         "minimum":0,
         "maximum":100
      },
      "description":{
         "title":"Description",
         "description":"Used for blog listing page and SEO description",
         "type":"string",
         "minLength":1,
         "maxLength":200
      },
      "image":{
         "title":"Image",
         "description":"Used for the blog post's thumbnail and banner",
         "allOf":[
            {
               "$ref":"http://bigcontent.io/cms/schema/v1/core#/definitions/content-link"
            },
            {
               "properties":{
                  "contentType":{
                     "enum":[
                        "https://schema-examples.com/example-image"
                     ]
                  }
               }
            }
         ]
      },
      "_meta":{
         "type":"object",
         "properties":{
            "deliveryKey":{
               "type":"string",
               "title":"Delivery key",
               "description":"The delivery key is used as the URL slug"
            }
         }
      },
      "readTime":{
         "title":"Read time",
         "description":"The time it takes to read the blog",
         "type":"integer"
      },
      "authors":{
         "title":"Blog author",
         "description":"Article author(s) - max 3",
         "type":"array",
         "minItems":1,
         "maxItems":3,
         "items":{
            "allOf":[
               {
                  "$ref":"http://bigcontent.io/cms/schema/v1/core#/definitions/content-link"
               },
               {
                  "properties":{
                     "contentType":{
                        "enum":[
                           "https://schema-examples.com/example-author"
                        ]
                     }
                  }
               }
            ]
         }
      },
      "content":{
         "title":"Content",
         "description":"",
         "type":"array",
         "minItems":1,
         "maxItems":20,
         "items":{
            "allOf":[
               {
                  "$ref":"http://bigcontent.io/cms/schema/v1/core#/definitions/content-link"
               },
               {
                  "properties":{
                     "contentType":{
                        "title":"Content",
                        "enum":[
                           "https://schema-examples.com/example-image",
                           "https://schema-examples.com/example-video",
                           "https://schema-examples.com/example-text"
                        ]
                     }
                  }
               }
            ]
         }
      },
      "category":{
         "title":"Category",
         "description":"description",
         "type":"string",
         "enum":[
            "Women",
            "Men",
            "Kids",
            "Beauty",
            "Homewares"
         ]
      }
   },
   "propertyOrder":[
      "title",
      "_meta",
      "authors",
      "category",
      "date",
      "ranking",
      "description",
      "image",
      "tags",
      "readTime",
      "content"
   ],
   "required":[
      "title",
      "authors",
      "date",
      "description",
      "image",
      "readTime",
      "content"
   ],
   "trait:sortable":{
      "sortBy":[
         {
            "key":"default",
            "paths":[
               "/date",
               "/ranking"
            ]
         },
         {
            "key":"readTime",
            "paths":[
               "/readTime",
               "/date",
               "/ranking"
            ]
         }
      ]
   },
   "trait:filterable":{
      "filterBy":[
         {
            "paths":[
               "/category"
            ]
         }
      ]
   }
}

Content form preview

An example of creating a content item using a content type registered from the blog post filter example schema is shown in the image below.

This includes author, text and image content items.

Adding a content item from the blog post filter example
Adding a content item from the blog post filter example

List, sort and filter content

Blog example

results matching ""

    No results matching ""