We figured we had to start somewhere, so how about the most basic of basic types of properties—a blog website?

Here's the scenario:

You are to create the structure for a simple blog site. The blog site should have posts. Post should have at least one category that can be added or adjusted by our editors, and a single featured image.

We also would like a simple toggle to know if a post should be published.

And last, we don't want editors to be able to add images randomly, only directly to a post.

Your configuration might look something like this:

[
  {
    "title": "Post",
    "fields": {
      "name": {
        "primary": true
      },
      "featured_image": {
        "type": "element",
        "templates": ["Image"]
      },
      "category": {
        "type": "elements",
        "templates": ["Category"],
        "required": true
      },
      "description": {
        "type": "text"
      },
      "body": {
        "type": "wysiwyg"
      },
      "published": {
        "type": "boolean"
      }
    }
  },
  {
    "title": "Image",
    "type": "document",
    "hidden": true,
    "fields": {
      "name": {
        "primary": true
      }
    }
  },
  {
    "title": "Category",
    "fields": {
      "name": {
        "primary": true
      }
    }
  }
]

A couple tricks to notice here:

  • We never specify "type": "string" for string fields because that's the default.
  • We don't add labels when they can be rendered using the field name.
  • We used "hidden": true to hide the images item from the sidebar.
  • We used elements instead of element for our association to category, as that will enable us to add more than one.
  • The category has the minimum amount of configuration needed for a template.