docs: update nested collection docs

This commit is contained in:
Daniel Lautzenheiser 2023-01-28 09:05:30 -05:00
parent abc8a567f3
commit 3a536c9871
2 changed files with 84 additions and 2 deletions

View File

@ -7,7 +7,7 @@
"build:docs": "cd packages/docs && yarn build", "build:docs": "cd packages/docs && yarn build",
"dev": "lerna run dev --scope @staticcms/core", "dev": "lerna run dev --scope @staticcms/core",
"demo": "lerna run dev --scope @staticcms/demo", "demo": "lerna run dev --scope @staticcms/demo",
"docs": "lerna run dev --scope docs", "docs": "lerna run dev --scope @staticcms/docs",
"format": "lerna run format", "format": "lerna run format",
"lint": "lerna run lint", "lint": "lerna run lint",
"prepare": "husky install", "prepare": "husky install",

View File

@ -294,7 +294,89 @@ Supports all of the [`slug` templates](/docs/configuration-options#slug) and:
### Nested Collections <img src="https://img.shields.io/badge/-Beta%20Feature-blue" alt="Beta Feature. Use at your own risk" title="Beta Feature. Use at your own risk" /> ### Nested Collections <img src="https://img.shields.io/badge/-Beta%20Feature-blue" alt="Beta Feature. Use at your own risk" title="Beta Feature. Use at your own risk" />
[Nested collections](/docs/beta-features/#nested-collections) is a beta feature that allows a folder collection to show a nested structure of entries and edit the locations of the entries. This feature is useful when you have a complex folder structure and may not want to create separate collections for every directory. As it is in beta, please use with discretion. Nested collections is a beta feature that allows a folder collection to show a nested structure of entries and edit the locations of the entries. This feature is useful when you have a complex folder structure and may not want to create separate collections for every directory. As it is in beta, please use with discretion.
Example configuration:
<CodeTabs>
```yaml
collections:
- name: pages
label: Pages
label_singular: 'Page'
folder: content/pages
create: true
# adding a nested object will show the collection folder structure
nested:
depth: 100 # max depth to show in the collection tree
summary: '{{title}}' # optional summary for a tree node, defaults to the inferred title field
fields:
- label: Title
name: title
widget: string
- label: Body
name: body
widget: markdown
# adding a meta object with a path property allows editing the path of entries
# moving an existing entry will move the entire sub tree of the entry to the new location
meta: { path: { widget: string, label: 'Path', index_file: 'index' } }
```
```js
{
"collections": [
{
"name": "pages",
"label": "Pages",
"label_singular": "Page",
"folder": "content/pages",
"create": true,
"nested": {
"depth": 100,
"summary": "{{title}}"
},
"fields": [
{
"label": "Title",
"name": "title",
"widget": "string"
},
{
"label": "Body",
"name": "body",
"widget": "markdown"
}
],
"meta": {
"path": {
"widget": "string",
"label": "Path",
"index_file": "index"
}
}
}
]
}
```
</CodeTabs>
Nested collections expect the following directory structure:
```bash
content
└── pages
├── authors
│ ├── author-1
│ │ └── index.md
│ └── index.md
├── index.md
└── posts
├── hello-world
│ └── index.md
└── index.md
```
## File Collections ## File Collections