feat(workflow): add deploy preview links (#2028)

This commit is contained in:
Shawn Erquhart
2019-02-08 12:26:59 -05:00
committed by GitHub
parent f0553c720a
commit 15d221d4a4
24 changed files with 861 additions and 42 deletions

View File

@ -85,10 +85,24 @@ media_library:
publicKey: demopublickey
```
## Site URL
The `site_url` setting should provide a URL to your published site. May be used by the CMS for
various functionality. Used together with a collection's `preview_path` to create links to live
content.
**Example:**
```yaml
display_url: https://your-site.com
```
## Display URL
When the `display_url` setting is specified, the CMS UI will include a link in the fixed area at the top of the page, allowing content authors to easily return to your main site. The text of the link consists of the URL less the protocol portion (e.g., `your-site.com`).
Defaults to `site_url`.
**Example:**
```yaml
@ -105,6 +119,16 @@ When the `logo_url` setting is specified, the CMS UI will change the logo displa
logo_url: https://your-site.com/images/logo.svg
```
## Show Preview Links
[Deploy preview links](../deploy-preview-links) can be disabled by setting `show_preview_links` to `false`.
**Example:**
```yaml
show_preview_links: false
```
## Slug Type
The `slug` option allows you to change how filenames for entries are created and sanitized. For modifying the actual data in a slug, see the per-collection option below.
@ -135,6 +159,7 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it
`collections` accepts a list of collection objects, each with the following options:
- `name` (required): unique identifier for the collection, used as the key when referenced in other contexts (like the [relation widget](../widgets/#relation))
- `identifier_field`: see detailed description below
- `label`: label for the collection in the editor UI; defaults to the value of `name`
- `label_singular`: singular label for certain elements in the editor; defaults to the value of `label`
- `description`: optional text, displayed below the label when viewing a collection
@ -146,11 +171,27 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it
- `format`: see detailed description below
- `frontmatter_delimiter`: see detailed description under `format`
- `slug`: see detailed description below
- `preview_path`: see detailed description below
- `fields` (required): see detailed description below
- `editor`: see detailed description below
The last few options require more detailed information.
### `identifier_field`
Netlify CMS expects every entry to provide a field named `"title"` that serves as an identifier for
the entry. The identifier field serves as an entry's title when viewing a list of entries, and is
used in [slug](#slug) creation. If you would like to use a field other than `"title"` as the
identifier, you can set `identifier_field` to the name of the other field.
**Example**
``` yaml
collections:
- name: posts
identifier_field: name
```
### `extension` and `format`
These settings determine how collection files are parsed and saved. Both are optional—Netlify CMS will attempt to infer your settings based on existing items in the collection. If your collection is empty, or you'd like more control, you can set these fields explicitly.
@ -174,11 +215,11 @@ You may also specify a custom `extension` not included in the list above, as lon
### `slug`
For folder collections where users can create new items, the `slug` option specifies a template for generating new filenames based on a file's creation date and `title` field. (This means that all collections with `create: true` must have a `title` field.)
For folder collections where users can create new items, the `slug` option specifies a template for generating new filenames based on a file's creation date and `title` field. (This means that all collections with `create: true` must have a `title` field (a different field can be used via [`identifier_field`](#identifier_field)).
**Available template tags:**
- `{{slug}}`: a url-safe version of the `title` field for the file
- `{{slug}}`: a url-safe version of the `title` field (or identifier field) for the file
- `{{year}}`: 4-digit year of the file creation date
- `{{month}}`: 2-digit month of the file creation date
- `{{day}}`: 2-digit day of the month of the file creation date
@ -192,6 +233,48 @@ For folder collections where users can create new items, the `slug` option speci
slug: "{{year}}-{{month}}-{{day}}_{{slug}}"
```
### `preview_path`
A string representing the path where content in this collection can be found on the live site. This
allows deploy preview links to direct to lead to a specific piece of content rather than the site
root of a deploy preview.
**Available template tags:**
- Any field can be referenced by wrapping the field name in double curly braces, eg. `{{author}}`
- `{{slug}}`: the entire slug for the current entry (not just the url-safe identifier, as is the
case with [`slug` configuration](#slug)
The following date based template tags are pulled from a date field in your entry, and may require additional configuration, see [`preview_path_date_field`](#preview_path_date_field) for details. If a date template tag is used and no date can be found, `preview_path` will be ignored.
- `{{year}}`: 4-digit year from entry data
- `{{month}}`: 2-digit month from entry data
- `{{day}}`: 2-digit day of the month from entry data
- `{{hour}}`: 2-digit hour from entry data
- `{{minute}}`: 2-digit minute from entry data
- `{{second}}`: 2-digit second from entry data
**Example:**
```yaml
collections:
- name: posts
preview_path: "blog/{{year}}/{{month}}/{{slug}}"
```
### `preview_path_date_field`
The name of a date field for parsing date-based template tags from `preview_path`. If this field is
not provided and `preview_path` contains date-based template tags (eg. `{{year}}`), Netlify CMS will
attempt to infer a usable date field by checking for common date field names, such as `date`. If you
find that you need to specify a date field, you can use `preview_path_date_field` to tell Netlify
CMS which field to use for preview path template tags.
**Example:**
```yaml
collections:
- name: posts
preview_path_date_field: "updated_on"
```
### `fields`
The `fields` option maps editor UI widgets to field-value pairs in the saved file. The order of the fields in your Netlify CMS `config.yml` file determines their order in the editor UI and in the saved file.