Skip to content

Commit

Permalink
merge-conflict removes beta-features.md as it's empty
Browse files Browse the repository at this point in the history
  • Loading branch information
privatemaker committed Jan 29, 2024
2 parents b4a9478 + 8d55122 commit 1fb8834
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 196 deletions.
2 changes: 2 additions & 0 deletions packages/decap-cms-locales/src/zh_Hans/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const zh_Hans = {
},
i18n: {
writingInLocale: '正在使用%{locale}撰写',
copyFromLocale: '用其他语言进行填充',
copyFromLocaleConfirm: '你确定要用“%{locale}”进行填充吗?\n这将会覆盖所有现有的内容。',
},
},
editor: {
Expand Down
2 changes: 2 additions & 0 deletions packages/decap-cms-locales/src/zh_Hant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const zh_Hant = {
},
i18n: {
writingInLocale: '以 %{locale} 書寫',
copyFromLocale: '用其他語言進行填充',
copyFromLocaleConfirm: '你確定要用“%{locale}”進行填充嗎?\n這將會覆蓋所有現有的內容。',
},
},
editor: {
Expand Down
195 changes: 0 additions & 195 deletions website/content/docs/beta-features.md

This file was deleted.

17 changes: 17 additions & 0 deletions website/content/docs/custom-mounting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Custom Mount Element
weight: 90
group: Customization
---

Decap CMS always creates its own DOM element for mounting the application, which means it always takes over the entire page, and is generally inflexible if you're trying to do something creative, like injecting it into a shared context.

You can now provide your own element for Decap CMS to mount in by setting the target element's ID as `id="nc-root"`. If Decap CMS finds an element with this ID during initialization, it will mount within that element instead of creating its own.

This is useful if you want to create a wrapper around the CMS, like a custom header, footer, or sidebar.

**Example**

Adding the following div to `admin/index.html` will cause the CMS to load within it:

<div id="nc-root"></div>
38 changes: 38 additions & 0 deletions website/content/docs/dynamic-default-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Dynamic Default Values
group: Fields
weight: 30
---

When linking to `/admin/#/collections/posts/new` you can pass URL parameters to pre-populate an entry.

For example given the configuration:

```yaml
collections:
- name: posts
label: Posts
folder: content/posts
create: true
fields:
- label: Title
name: title
widget: string
- label: Object
name: object
widget: object
fields:
- label: Title
name: title
widget: string
- label: body
name: body
widget: markdown
```
clicking the following link: `/#/collections/posts/new?title=first&object.title=second&body=%23%20content`

will open the editor for a new post with the `title` field populated with `first`, the nested `object.title` field
with `second` and the markdown `body` field with `# content`.

**Note:** URL Encoding might be required for certain values (e.g. in the previous example the value for `body` is URL encoded).
27 changes: 27 additions & 0 deletions website/content/docs/registering-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Registering to CMS Events
weight: 80
group: Customization
---

You can execute a function when a specific CMS event occurs.

Example usage:

```javascript
CMS.registerEventListener({
name: 'prePublish',
handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })),
});
```

Supported events are `prePublish`, `postPublish`, `preUnpublish`, `postUnpublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:

```javascript
CMS.registerEventListener({
name: 'preSave',
handler: ({ entry }) => {
return entry.get('data').set('title', 'new title');
},
});
```
83 changes: 83 additions & 0 deletions website/content/docs/variable-type-widgets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
label: "Variable Type Widgets"
group: Fields
weight: 30
---

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 Decap CMS.

**Note: this feature does not yet support default previews and requires [registering a preview template](/docs/customization#registerpreviewtemplate) in order to show up in the preview pane.**

To use variable types in the list widget, update your field configuration as follows:

1. Instead of defining your list fields under `fields` or `field`, define them under `types`. Similar to `fields`, `types` must be an array of field definition objects.
2. Each field definition under `types` must use the `object` widget (this is the default value for
`widget`).

### Additional list widget options

* `types`: a nested list of object widgets. All widgets must be of type `object`. Every object widget may define different set of fields.
* `typeKey`: the name of the field that will be added to every item in list representing the name of the object widget that item belongs to. Ignored if `types` is not defined. Default is `type`.
* `summary`: allows customization of a collapsed list item object in a similar way to a [collection summary](/docs/configuration-options/?#summary)

### Example Configuration

The example configuration below imagines a scenario where the editor can add two "types" of content,
either a "carousel" or a "spotlight". Each type has a unique name and set of fields.

```yaml
- label: 'Home Section'
name: 'sections'
widget: 'list'
types:
- label: 'Carousel'
name: 'carousel'
widget: object
summary: '{{fields.header}}'
fields:
- { label: Header, name: header, widget: string, default: 'Image Gallery' }
- { label: Template, name: template, widget: string, default: 'carousel.html' }
- label: Images
name: images
widget: list
field: { label: Image, name: image, widget: image }
- label: 'Spotlight'
name: 'spotlight'
widget: object
fields:
- { label: Header, name: header, widget: string, default: 'Spotlight' }
- { label: Template, name: template, widget: string, default: 'spotlight.html' }
- { label: Text, name: text, widget: text, default: 'Hello World' }
```
### Example Output
The output for the list widget will be an array of objects, and each object will have a `type` key
with the name of the type used for the list item. The `type` key name can be customized via the
`typeKey` property in the list configuration.

If the above example configuration were used to create a carousel, a spotlight, and another
carousel, the output could look like this:

```yaml
title: Home
sections:
- type: carousel
header: Image Gallery
template: carousel.html
images:
- images/image01.png
- images/image02.png
- images/image03.png
- type: spotlight
header: Spotlight
template: spotlight.html
text: Hello World
- type: carousel
header: Image Gallery
template: carousel.html
images:
- images/image04.png
- images/image05.png
- images/image06.png
```
12 changes: 12 additions & 0 deletions website/content/docs/widgets/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ The file widget allows editors to upload a file or select an existing one from t
config:
multiple: true
```
### 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 file field.
**Example**
```yaml
media_library:
config:
max_file_size: 1024000 # in bytes, only for default media library
```
Loading

0 comments on commit 1fb8834

Please sign in to comment.