Feat: media folders templates (#3116)
* refactor: typescript backendHelper * test: add string templating tests * test: add createPreviewUrl invalid date test * refactor: move all formatters to one file * feat: support media folders templating * feat: add filename and extension template variables * feat: support paths in string templates * docs: add media folder templating docs * style(docs): remove line break
This commit is contained in:
committed by
Shawn Erquhart
parent
4bc4490c6f
commit
cf57da223d
@ -55,7 +55,7 @@ You can now specify a `path` template (similar to the `slug` template) to contro
|
||||
|
||||
This allows saving content in subfolders, e.g. configuring `path: '{{year}}/{{slug}}'` will save the content under `2019/post-title.md`.
|
||||
|
||||
## Folder Collections Media Folder
|
||||
## Folder Collections Media and Public Folder
|
||||
|
||||
By default the CMS stores media files for all collections under a global `media_folder` directory as specified in the configuration.
|
||||
|
||||
@ -86,6 +86,7 @@ collections:
|
||||
folder: content/posts
|
||||
path: '{{slug}}/index'
|
||||
media_folder: ''
|
||||
public_folder: ''
|
||||
fields:
|
||||
- label: Title
|
||||
name: title
|
||||
@ -97,7 +98,7 @@ collections:
|
||||
|
||||
More specifically, saving a entry with a title of `example post` with an image named `image.png` will result in a directory structure of:
|
||||
|
||||
```
|
||||
```bash
|
||||
content
|
||||
posts
|
||||
example-post
|
||||
@ -109,6 +110,15 @@ And for the image field being populated with a value of `image.png`.
|
||||
|
||||
**Note: When specifying a `path` on a folder collection `media_folder` defaults to an empty string.**
|
||||
|
||||
**Available template tags:**
|
||||
|
||||
Supports all of the [`slug` templates](/docs/configuration-options#slug) and:
|
||||
|
||||
* `{{filename}}` The file name without the extension part.
|
||||
* `{{extension}}` The file extension.
|
||||
* `{{media_folder}}` The global `media_folder`.
|
||||
* `{{public_folder}}` The global `public_folder`.
|
||||
|
||||
## List Widget: Variable Types
|
||||
|
||||
Before this feature, the [list widget](/docs/widgets/#list) allowed a set of fields to be repeated, but every list item had the same set of fields available. With variable types, multiple named sets of fields can be defined, which opens the door to highly flexible content authoring (even page building) in Netlify CMS.
|
||||
@ -343,7 +353,6 @@ Template tags produce the following output:
|
||||
|
||||
- `{{author-name}}`: the full name of the author (might be empty based on the user's profile)
|
||||
|
||||
|
||||
## Image widget file size limit
|
||||
|
||||
You can set a limit to as what the maximum file size of a file is that users can upload directly into a image field.
|
||||
@ -359,4 +368,3 @@ Example config:
|
||||
config:
|
||||
max_file_size: 512000 # in bytes, only for default media library
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user