-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into docs/beta-features/widget-variable-types
- Loading branch information
Showing
8 changed files
with
111 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters