Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add description-html-formatting-docs (PR from TinaCMS) #2375

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions content/docs/reference/collections.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
id: collections

title: Collections
last_edited: '2023-03-01T15:51:56.737Z'
last_edited: '2024-10-29T07:27:46.292Z'
next: content/docs/reference/fields.mdx
previous: content/docs/reference/schema.mdx
---
Expand All @@ -16,21 +15,23 @@ Collections represent a type of content (EX, blog post, page, author, etc). We r
| [`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. |
| [`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_) |
| `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*) |
| `ui.filename.description` | A short description for the filename field that will be displayed to the user (*optional*, can include html formatting e.g. style attributes) |
| `ui.filename.showFirst` | A boolean that if true will render the filename field at the top of the form (*optional*, default `false`) |

> Note: Must provide only one of `fields` or `templates` but never both

Expand Down Expand Up @@ -78,7 +79,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 @@ -101,11 +102,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
3 changes: 2 additions & 1 deletion content/docs/reference/fields.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Although some fields have more properties here is a list of common ones that are
| `name` | The name of the field |
| `type` | The [type of the field](/docs/reference/types/) to be used |
| `label` | A human friendly label that will be displayed to the user (*optional*, defaults to `name`) |
| `description` | A short description about the field that will be displayed to the user (*optional*, can include html formatting e.g. style attributes) |
| `required` | If `true`, the collection cannot be saved without this field present (*optional*, defaults to `false`) |
| `isTitle` | Denote a field as the title of a collection. [See below for more details](#istitle) (*optional*, defaults to `false`) |
| `isBody` | If `true` this field will be used as the body of the document. [See below for more details](#isbody) (*optional*, defaults to `false`) |
Expand Down Expand Up @@ -120,7 +121,7 @@ export default defineConfig({
}
```

`ui.min` will ensure that once the specified minimum number of items is added (ex: 3 in the example), users will not be able to remove items if there are only the minimum number of items.
`ui.min` will ensure that once the specified minimum number of items is added (ex: 3 in the example), users will not be able to remove items if there are only the minimum number of items.

It can apply to all field types with list `list: true` specified, provided they appear as a list in the editor. Specifically, this is the:

Expand Down