Skip to main content

Blog post filter schema example

The blog post filter example is used to introduce the features of the Content Delivery and GraphQL Content Delivery 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
Link copied!

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
Link copied!

Once you've registered the schemas from this page, you will be able to follow the examples on the Content Delivery and GraphQL Content Delivery filter pages.

Blog post filter
Link copied!

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.

The schema also includes GraphQL specific additions: graphql:filtername and graphql:sortname.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema-examples.com/blog-post-filter",
"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"]
},
{
"graphql:sortname": "byTime",
"key": "readTime",
"paths": ["/readTime", "/date", "/ranking"]
}
]
},
"trait:filterable": {
"filterBy": [
{
"graphql:filtername": "byCategory",
"paths": ["/category"]
}
]
}
}

Content form preview
Link copied!

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

Content Delivery filter API

GraphQL Content Delivery filter API

Blog example