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

sort_options

Table of contents

Description:

This key defines the options for the Sort dropdown in a Collection browser.

Configuring sort options for a Collection will remove CloudCannon's default sorting options from the Sort dropdown.

By default, CloudCannon provides sorting options for path, file size, file creation time, and last modified, in ascending and descending order.

CloudCannon will also read data keys from your early Collection files and provide options to sort by those key values.

Appears in:
└── collections_config
    └── *
        └── sort_options
Type:
Array<sort_options[*]>
Items:
[*]Object#

This key represents a sort option for a Collection.

Examples:

In this example, the Sort dropdown in the blog Collection browser only contains options for sorting by author and date in ascending and descending order.

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