decaporg / decaporg/decap-cms

Collection Capabilities

Open
#3,683 2 comments 0 reactions 0 assignees View on GitHub
area: configuration area: ux type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

## What is a collection capability

Collection capabilities are like presets in that the collection would be configured a certain way without having to specify everything implicitly in your `config.yml`.

For example (warning: pseudo code), this….
```yml
collections: [
{
name: "posts",
label: "Posts",
capabilities: ["category", "tag"]
}
]
```
would be the same thing as this…
```yml
collections: [
{
name: "posts",
label: "Posts",
fields: [
{ name: "category", label: "Category", widget: "relation", collection: "postCategories", ... },
{ name: "category", label: "Tags", widget: "relation", collection: "postTags", multiple: true, ... }
]
},
{ name: "postCategories", "Post Categories", ... },
{ name: "postTags", "Post Tags", ... }
]
```

Tags could be stored in a single file per #3542 and new tags would be added when the user adds a non-existent tag to the tag input on save per #192.

## Beyond simplified collection config

Of course these capabilities could be much more complex in that they are more than simply shortcuts to adding more config but they also add additional functionality such as tie the collection to an external data source via an API via #3684.

For example…
```yml
{
name: "authors",
label: "Authors",
capabilities: ["users"]
}
```
The authors collection would then mirror the users you have given access to access your CMS. Any additional information associated with that user can be stored in the CMS without having to store sensitive information such as passwords in your git repo (as mentioned in #3684).

## Configuring the capability

We could take this a step further and add some config to these capabilities, for example

```yml
collections: [
{
name: "posts",
label: "Posts",
capabilities: [
{ name: "category", collection: { name: "postCategories", ... },
{ name: "tags", multiple: false, collection: { name: "postTags", ... }
]
}
]
```

This may for example allow for overrides or additional fields within these collections.

Thoughts about this approach?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.