forked from contentful/contentful-migration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path35-create-editor-layout.js
More file actions
33 lines (27 loc) · 1.2 KB
/
35-create-editor-layout.js
File metadata and controls
33 lines (27 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Demonstrates how to create an editor layout with field groups and tabs.
*/
module.exports = function (migration) {
const page = migration.createContentType('page').name('Page')
page.createField('name').name('Internal name').type('Symbol')
page.createField('title').name('Page title').type('Symbol')
// an editor layout can be created empty but not saved without adding at least one tab
const editorLayout = page.createEditorLayout()
// create the field group that will become the top level tab
editorLayout.createFieldGroup('content', {
name: 'Content'
})
// make the Content field group a top level tab
editorLayout.changeFieldGroupControl('content', 'builtin', 'topLevelTab', {
helpText: 'Main content'
})
// create field groups inside the content tab
editorLayout.createFieldGroup('settings').name('Settings')
editorLayout.editFieldGroup('settings').createFieldGroup('seo').name('SEO')
// change the field group control to a fieldset (this is what makes it a section)
editorLayout.changeFieldGroupControl('seo', 'builtin', 'fieldset', {
helpText: 'Search related fields',
collapsedByDefault: false
})
editorLayout.createFieldGroup('metadata').name('Metadata')
}