feat: allow per-file preview_path in file collection (#4413)

This commit is contained in:
stefanprobst
2020-10-15 16:21:36 +02:00
committed by GitHub
parent a5750d782e
commit 9e0b8ac4b8
5 changed files with 105 additions and 14 deletions

View File

@ -12,7 +12,7 @@ of your unmerged content.
Deploy preview links will work without configuration when all of the following requirements are met:
* Netlify CMS version is 2.4.0+ for GitHub support and 2.10.6+ for GitLab/Bitbucket support
* Netlify CMS version is 2.4.0+ for GitHub support and 2.10.6+ for GitLab/Bitbucket support
* Using editorial workflow
* Have a continuous deployment platform that builds every commit and provides statuses to your repo
@ -40,7 +40,7 @@ pending, which a content editor can use to manually check for a finished preview
Deploy preview links point to the site root by default, but you'll probably want them to point to
the specific piece of content that the content editor is viewing. You can do this by providing a
`preview_path` string template for each collection.
`preview_path` string template for each collection, or for inidividual files in a files collection.
Let's say we have a `blog` collection that stores content in our repo under `content/blog`. The path
to a post in your repo may look like `content/blog/2018-01-new-post.md`, but the path to that post
@ -55,6 +55,18 @@ collections:
preview_path: blog/{{slug}}
```
Similarly, for an `about` page in a files collection under `content/pages` which maps to `/about-the-project`
on your site, you would configure `preview_path` like this:
```yaml
collections:
- name: pages
files:
- name: about
file: content/pages/about.md
preview_path: about-the-project
```
With the above configuration, the deploy preview URL from your backend will be combined with your
preview path to create a URL to a specific blog post.
@ -134,4 +146,4 @@ a commit status back to your repository host with the URL.
The deploy preview URL provided by a backend will lead to the root of the deployed site. Netlify CMS
will then use the `preview_path` template in an entry's collection configuration to build a path to
a specific piece of content. If a `preview_path` is not provided for an entry's collection, the URL
will be used as is.
will be used as is.