Skip to content

Commit

Permalink
add folder (PR from TinaCMS) (#1857)
Browse files Browse the repository at this point in the history
Co-authored-by: tina-cloud-app[bot] <58178390+tina-cloud-app[bot]@users.noreply.github.com>
Co-authored-by: Jack Pettit <jpr178@live.com.au>
Co-authored-by: Jack Pettit [SSW] <57518417+JackDevAU@users.noreply.github.com>
Co-authored-by: Nick Curran [SSW] <132531112+ncn-ssw@users.noreply.github.com>
  • Loading branch information
4 people committed Jun 18, 2024
1 parent 4dbd9ce commit d3690f9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
56 changes: 29 additions & 27 deletions content/docs/reference/collections.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
---
title: Collections
id: collections
title: Collections
last_edited: '2023-03-01T15:51:56.737Z'
next: /docs/reference/fields
prev: /docs/reference/schema
next: /docs/reference/fields
---

Collections represent a type of content (EX, blog post, page, author, etc). We recommend using singular naming in a collection (Ex: use post and not posts).

## Overview

| Property | Description |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`name`](#name) | The name of the collection |
| [`path`](#path) | The path (relative to where the CLI is running) to a folder where the content is stored. |
| [`format`](#format) | The extension of all the documents in this collection (Default is "md"). Must be one of `"md"`, `"markdown"`, `"mdx"`,`"json"`, `"toml"`, or `"yaml"`. |
| [`match.include`](#match.include) | A [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>) (without the file extension) that will be used to match a subset of the files in the `path` folder. |
| [`match.exclude`](#match.exclude) | A [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>) (without the file extension) that will be used to exclude a subset of the files in the `path` folder. |
| `label` | A human friendly label that will be displayed to the user |
| `fields` | An array of [fields](/docs/reference/fields/) |
| `templates` | An array of [templates](/docs/reference/templates/) |
| [`defaultItem`](#defaultitem) | An object or a function that returns an object. The object that is returned will be the data used as the default data when a new document is created. |
| `frontmatterFormat` | The format used to parse the frontmatter. This can be `"yaml"` ,`"toml"`, or `"json"`. It defaults to `"yaml"` |
| `frontmatterDelimiters` | The Delimiters used for the frontmatter for a document. This is what Has type `string \| [string, string]` . The default is `---`. Read more about delimiters [here](https://github.com/jonschlinkert/gray-matter#optionsdelimiters) |
| `ui.filename` | See [Filename customization](/docs/extending-tina/filename-customization/) |
| `ui.beforeSubmit` | This function is called before the form is submitted. If values are returned from this function they will be the values used to submit the form. (_optional_) |
| `ui.global` | A boolean that if true will make this collection Global. (_optional_) |
| `ui.router` | A function that takes in a document and returns the route for it. If nothing is returned the basic editor will be used. Read more about visual editing [here](/docs/contextual-editing/router/#the-router-property)(_optional_) |
| `ui.allowedActions.create` | If this is false, the create button will not appear in the collection list page. See [example](#example-with-allowed-actions). (_optional_) |
| `ui.allowedActions.delete` | If this is false, the create delete button will not appear in the collection list page. See [example](#example-with-allowed-actions). (_optional_) |
| Property | Description |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`name`](#name) | The name of the collection |
| [`path`](#path) | The path (relative to where the CLI is running) to a folder where the content is stored. |
| [`format`](#format) | The extension of all the documents in this collection (Default is "md"). Must be one of `"md"`, `"markdown"`, `"mdx"`,`"json"`, `"toml"`, or `"yaml"`. |
| [`match.include`](#match.include) | A [glob pattern](https://en.wikipedia.org/wiki/Glob_\(programming\)) (without the file extension) that will be used to match a subset of the files in the `path` folder. |
| [`match.exclude`](#match.exclude) | A [glob pattern](https://en.wikipedia.org/wiki/Glob_\(programming\)) (without the file extension) that will be used to exclude a subset of the files in the `path` folder. |
| `label` | A human friendly label that will be displayed to the user |
| `fields` | An array of [fields](/docs/reference/fields/) |
| `templates` | An array of [templates](/docs/reference/templates/) |
| [`defaultItem`](#defaultitem) | An object or a function that returns an object. The object that is returned will be the data used as the default data when a new document is created. |
| `frontmatterFormat` | The format used to parse the frontmatter. This can be `"yaml"` ,`"toml"`, or `"json"`. It defaults to `"yaml"` |
| `frontmatterDelimiters` | The Delimiters used for the frontmatter for a document. This is what Has type `string \| [string, string]` . The default is `---`. Read more about delimiters [here](https://github.com/jonschlinkert/gray-matter#optionsdelimiters) |
| `ui.filename` | See [Filename customization](/docs/extending-tina/filename-customization/) |
| `ui.beforeSubmit` | This function is called before the form is submitted. If values are returned from this function they will be the values used to submit the form. (*optional*) |
| `ui.global` | A boolean that if true will make this collection Global. (*optional*) |
| `ui.router` | A function that takes in a document and returns the route for it. If nothing is returned the basic editor will be used. Read more about visual editing [here](/docs/contextual-editing/router/#the-router-property)(*optional*) |
| `ui.allowedActions.create` | If this is false, the create button will not appear in the collection list page. See [example](#example-with-allowed-actions). (*optional*) |
| `ui.allowedActions.delete` | If this is false, the create delete button will not appear in the collection list page. See [example](#example-with-allowed-actions). (*optional*) |
| `ui.allowedActions.createNestedFolder` | If this is false, the create folder button will not appear in the collection list page. See [example](#example-with-allowed-actions). (*optional*) |

> Note: Must provide only one of `fields` or `templates` but never both
Expand Down Expand Up @@ -76,7 +77,7 @@ export const defineConfig({

## match.include

A [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>) that will be used to match a subset of the files in the `path` directory.
A [glob pattern](https://en.wikipedia.org/wiki/Glob_\(programming\)) that will be used to match a subset of the files in the `path` directory.

The provided pattern does not have to include the file extension. The extension will be added automatically based on the [`format`](#format) of the collection. The final pattern that is used will be determined by `match`, `format` and `path`.

Expand All @@ -99,11 +100,11 @@ The final pattern used would be

### Basic Syntax

- `?` matches a single character
- `*` matches any number of any characters (except `/`).
- `[abc]` matches any one character in the given set
- `[a-z]` matches a range.
- `{foo,bar}` matches any whole word in the given set
* `?` matches a single character
* `*` matches any number of any characters (except `/`)
* `[abc]` matches any one character in the given set
* `[a-z]` matches a range.
* `{foo,bar}` matches any whole word in the given set

### Some common glob patterns

Expand Down Expand Up @@ -352,6 +353,7 @@ export default defineConfig({
allowedActions: {
create: false,
delete: false,
createNestedFolder: false,
},
},
format: 'json',
Expand Down
15 changes: 9 additions & 6 deletions content/docs/using-tina-editor.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Using the Tina Editor
id: /docs/using-tina-editor/
title: Using the Tina Editor
last_edited: '2022-01-09T00:00:00.000Z'
next: '/docs/schema'
next: /docs/schema
---

Tina is very flexible & extendable, so any Tina site may have a unique experience. As an introduction, we'll cover the out-of-the-box experience that most of our starters implement.
Expand All @@ -25,7 +25,10 @@ Depending on how Tina is configured, one or more Collections will appear in the

![Tina Editor List Page](/img/tina-list-page.png)

The table here lists all documents for the chosen Collection. This page also allows the user to create a new document.
The table here lists all documents for the chosen Collection. This page also allows the user to create a new document or a new folder see below.

![](https://res.cloudinary.com/forestry-demo/image/upload/v1718664908/add-folder-tinacms_c8pxte.png)\
Can create folders to manage content.

If **contextual-editing** has been configured, clicking on a document will navigate the user to that document's preview with the Sidebar open and ready for editing.

Expand All @@ -43,6 +46,6 @@ Once saved, the changes to the document will be stored against the files.

There's plenty to do to customize your editing experience. We suggest:

- Checking out [our concept docs](/docs/schema/), to learn how Tina powers the starters under the hood.
- Learn how [Tina can be extended](/docs/advanced/extending-tina/) to create new field components
- Make your site [editable with Tina on production](/docs/tina-cloud/)
* Checking out [our concept docs](/docs/schema/), to learn how Tina powers the starters under the hood
* Learn how [Tina can be extended](/docs/advanced/extending-tina/) to create new field components
* Make your site [editable with Tina on production](/docs/tina-cloud/)

0 comments on commit d3690f9

Please sign in to comment.