decaporg / decaporg/decap-cms

Feature - Add a limit to folder collection sizes

Open
#7,417 2 comments 2 reactions 1 assignee Claimed by @RohitPeswani View on GitHub
type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Is your feature request related to a problem? Please describe.**
Not that I'm aware of

**Describe the solution you'd like**
I would like to be able to limit the number of entries a user can create within a collection. This could be configured in `config.yml` in a way similar to below:
```
collections:
- name: "blog" # Used in routes, e.g., /admin/collections/blog
label: "Blog" # Used in the UI
limit: 25 # Only a maximum of 25 blog posts can be made in this collection
folder: "_posts/blog" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- { label: "Layout", name: "layout", widget: "hidden", default: "blog" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "date", widget: "datetime" }
- { label: "Featured Image", name: "thumbnail", widget: "image" }
- { label: "Rating (scale of 1-5)", name: "rating", widget: "number" }
- { label: "Body", name: "body", widget: "markdown" }
```

When the user creates 25 posts, the Create New button would be disabled, perhaps with a warning text saying that they have hit their 25 page limit

**Describe alternatives you've considered**
The only alternative I've thought of would be to use an event or some custom JS within the page where Decap is loaded and implement this manually. Or create a webhook that notifies me to go into the config.yml file to change `create` to `false` when the limit is hit. Both of these seem like very hack-y solutions to something I would've thought could be native functionality

**Additional context**

N/A

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.