☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

sort_options[*]

Table of contents

Description:

This key represents a sort option for a Collection.

Appears in:
└── collections_config
    └── *
        └── sort_options
            └── [*]
Type:
Object
Properties:
keystring Required#

This key defines which key an option in the Sort dropdown should use to sort files in your Collection browser.

You must define this key for every entry in the sort_options array for the object to function.

Value must be the name of a structured data key in your Collection files.

If some files in your Collection do not have this data key, CloudCannon will sort those in ascending alphabetical order, after the file sorted by your data key in the Collection browser.

Show examplesHide examples

In this example, the "Author (A-Z)" option in the Sort dropdown will use the author key to sort files in the blog Collection browser.

Copied to clipboard
collections_config:
  blog:
    sort_options:
      - key: author
        order: ascending
        label: Author (A-Z)
{
  "collections_config": {
    "blog": {
      "sort_options": [
        {
          "key": "author",
          "order": "ascending",
          "label": "Author (A-Z)"
        }
      ]
    }
  }
}
labelstring#

This key defines the label used for a file sorting option in the Sort dropdown.

Show examplesHide examples

In this example, the sorting method which uses the author key is called "Author (A-Z)" in the Sort dropdown.

Copied to clipboard
collections_config:
  blog:
    sort_options:
      - key: author
        order: ascending
        label: Author (A-Z)
{
  "collections_config": {
    "blog": {
      "sort_options": [
        {
          "key": "author",
          "order": "ascending",
          "label": "Author (A-Z)"
        }
      ]
    }
  }
}
orderstring#

This key defines which order an option in the Sort dropdown should use to sort files in your Collection browser.

CloudCannon will sort files according to the value of sort_options[*].key for each option in the Sort dropdown.

Defaults to: ascending

Allowed values: ascending descending asc desc

Show examplesHide examples

In this example, the "Author (A-Z)" option in the Sort dropdown will sort files in the blog Collection browser in ascending order.

Copied to clipboard
collections_config:
  blog:
    sort_options:
      - key: author
        order: ascending
        label: Author (A-Z)
{
  "collections_config": {
    "blog": {
      "sort_options": [
        {
          "key": "author",
          "order": "ascending",
          "label": "Author (A-Z)"
        }
      ]
    }
  }
}
Examples:
Open in a new tab