feat(config): add support for setting custom identifier field (#1543)

This commit is contained in:
Matt Kane
2018-11-01 18:02:11 +00:00
committed by Shawn Erquhart
parent 288359da3b
commit 12418dd7f0
4 changed files with 24 additions and 6 deletions

View File

@ -13,7 +13,7 @@ Folder collections represent one or more files with the same format, fields, and
Unlike file collections, folder collections have the option to allow editors to create new items in the collection. This is set by the boolean `create` field.
**Note:** Folder collections must have at least one field with the name `title` for creating new entry slugs. That field should use the default `string` widget. The `label` for the field can be any string value. See the [Collections reference doc](../configuration-options/#collections) for details on how collections and fields are configured. If you forget to add this field, you will get an error that your collection "must have a field that is a valid entry identifier".
**Note:** Folder collections must have at least one field with the name `title` for creating new entry slugs. That field should use the default `string` widget. The `label` for the field can be any string value. If you wish to use a different field as your identifier, set `identifier_field` to the field name. See the [Collections reference doc](../configuration-options/#collections) for details on how collections and fields are configured. If you forget to add this field, you will get an error that your collection "must have a field that is a valid entry identifier".
Example:
@ -30,6 +30,21 @@ collections:
- {label: "Body", name: "body", widget: "markdown"}
```
With `identifier_field`:
```yaml
- label: "Blog"
name: "blog"
folder: "_posts/blog"
create: true
identifier_field: name
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
```
### Filtered folder collections
The entries for any folder collection can be filtered based on the value of a single field. By filtering a folder into different collections, you can manage files with different fields, options, extensions, etc. in the same folder.