docs: make widget docs editable (#1782)
* make widget docs editable * update widget doc frontmatter keys * improve docs preview * fix formatting * fix preview * add prism highlighting for previews * fix formatting * restore cms branch
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: boolean
|
||||
label: "Boolean"
|
||||
target: boolean
|
||||
---
|
||||
|
||||
The boolean widget translates a toggle switch input to a true/false value.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: date
|
||||
label: "Date"
|
||||
target: date
|
||||
---
|
||||
|
||||
The date widget translates a date picker input to a date string. For saving date and time together, use the datetime widget.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: datetime
|
||||
label: "DateTime"
|
||||
target: datetime
|
||||
---
|
||||
|
||||
The datetime widget translates a datetime picker to a datetime string. For saving the date only, use the date widget.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "File"
|
||||
target: file
|
||||
title: file
|
||||
---
|
||||
|
||||
The file widget allows editors to upload a file or select an existing one from the media library. The path to the file will be saved to the field as a string.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Hidden"
|
||||
target: hidden
|
||||
title: hidden
|
||||
---
|
||||
|
||||
Hidden widgets do not display in the UI. In folder collections that allow users to create new items, you will often want to set a default for hidden fields, so they will be set without requiring an input.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Image"
|
||||
target: image
|
||||
title: image
|
||||
---
|
||||
|
||||
The image widget allows editors to upload an image or select an existing one from the media library. The path to the image file will be saved to the field as a string.
|
||||
|
@ -1,29 +0,0 @@
|
||||
---
|
||||
title: Widgets
|
||||
weight: 30
|
||||
group: reference
|
||||
---
|
||||
|
||||
Widgets define the data type and interface for entry fields. Netlify CMS comes with several built-in widgets. Click the widget names in the sidebar to jump to specific widget details. We’re always adding new widgets, and you can also [create your own](../custom-widgets)!
|
||||
|
||||
Widgets are specified as collection fields in the Netlify CMS `config.yml` file. Note that [YAML syntax](https://en.wikipedia.org/wiki/YAML#Basic_components) allows lists and objects to be written in block or inline style, and the code samples below include a mix of both.
|
||||
|
||||
To see working examples of all of the built-in widgets, try making a 'Kitchen Sink' collection item on the [CMS demo site](https://cms-demo.netlify.com). (No login required: click the login button and the CMS will open.) You can refer to the demo [configuration code](https://github.com/netlify/netlify-cms/blob/master/dev-test/config.yml) to see how each field was configured.
|
||||
|
||||
|
||||
## Common widget options
|
||||
|
||||
The following options are available on all fields:
|
||||
|
||||
- `required`: specify as `false` to make a field optional; defaults to `true`
|
||||
- `hint`: optionally add helper text directly below a widget. Useful for including instructions.
|
||||
- `pattern`: add field validation by specifying a list with a [regex pattern](https://regexr.com/) and an error message; more extensive validation can be achieved with [custom widgets](../custom-widgets/#advanced-field-validation)
|
||||
- **Example:**
|
||||
```yaml
|
||||
- label: "Title"
|
||||
name: "title"
|
||||
widget: "string"
|
||||
pattern: [".{12,}", "Must have at least 12 characters"]
|
||||
```
|
||||
|
||||
## Default widgets
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "List"
|
||||
target: list
|
||||
title: list
|
||||
---
|
||||
|
||||
The list widget allows you to create a repeatable item in the UI which saves as a list of widget values. map a user-provided string with a comma delimiter into a list. You can choose any widget as a child of a list widget—even other lists.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Markdown"
|
||||
target: markdown
|
||||
title: markdown
|
||||
---
|
||||
|
||||
The markdown widget provides a full fledged text editor - which is based on [slate](https://github.com/ianstormtaylor/slate) - that allows users to format text with features such as headings and blockquotes. Users are also allowed to write in markdown by simply flipping a switch.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Number"
|
||||
target: number
|
||||
title: number
|
||||
---
|
||||
|
||||
The number widget uses an HTML number input, saving the value as a string, integer, or floating point number.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Object"
|
||||
target: object
|
||||
title: object
|
||||
---
|
||||
|
||||
The object widget allows you to group multiple widgets together, nested under a single field. You can choose any widget as a child of an object widget—even other objects.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Relation"
|
||||
target: relation
|
||||
title: relation
|
||||
---
|
||||
|
||||
The relation widget allows you to reference items from another collection. It provides a search input with a list of entries from the collection you're referencing, and the list automatically updates with matched entries based on what you've typed.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Select"
|
||||
target: select
|
||||
title: select
|
||||
---
|
||||
|
||||
The select widget allows you to pick a single string value from a dropdown menu.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "String"
|
||||
target: string
|
||||
title: string
|
||||
---
|
||||
|
||||
The string widget translates a basic text input to a string value. For larger textarea inputs, use the text widget.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
label: "Text"
|
||||
target: text
|
||||
title: text
|
||||
---
|
||||
|
||||
The text widget takes a multiline text field and saves it as a string. For shorter text inputs, use the string widget.
|
||||
|
Reference in New Issue
Block a user