-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: image text slide and group content types (#2337)
* Migration to create image text slide and group content types and add it to story sections * rename migration * cleanup; update texts --------- Co-authored-by: lbiedinger <[email protected]>
- Loading branch information
1 parent
7e089c8
commit 1d361f4
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
packages/contentful/migrations/0135-create-image-text-group.cjs
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,105 @@ | ||
module.exports = function(migration) { | ||
const imageTextSlide = migration | ||
.createContentType('imageTextSlide') | ||
.name('Image text slide') | ||
.description('An image with text, used in stories') | ||
.displayField('name'); | ||
|
||
imageTextSlide | ||
.createField('name') | ||
.name('Name') | ||
.type('Symbol') | ||
.localized(false) | ||
.required(true) | ||
.validations([]) | ||
.disabled(false) | ||
.omitted(false); | ||
|
||
imageTextSlide | ||
.createField('image') | ||
.name('Image') | ||
.type('Link') | ||
.localized(false) | ||
.required(true) | ||
.validations([ | ||
{ | ||
linkContentType: ['imageWithAttribution'] | ||
} | ||
]) | ||
.disabled(false) | ||
.omitted(false) | ||
.linkType('Entry'); | ||
|
||
imageTextSlide | ||
.createField('text') | ||
.name('Text') | ||
.type('Text') | ||
.localized(true) | ||
.required(false) | ||
.validations([{ size: { max: 200 }, | ||
message: 'Text must be max. 200 characters.' }]) | ||
.disabled(false) | ||
.omitted(false); | ||
|
||
imageTextSlide.changeFieldControl('image', 'builtin', 'entryLinkEditor', { | ||
helpText: 'Use a high resolution and good quality image. For best quality it\'s advised to use images of at least 2,520 px width.' | ||
}); | ||
imageTextSlide.changeFieldControl('text', 'builtin', 'markdown', {}); | ||
|
||
const imageTextSlideGroup = migration | ||
.createContentType('imageTextSlideGroup') | ||
.name('Image text slide group') | ||
.description('A group of image text slides, used in stories') | ||
.displayField('name'); | ||
|
||
imageTextSlideGroup | ||
.createField('name') | ||
.name('Name') | ||
.type('Symbol') | ||
.localized(false) | ||
.required(true) | ||
.validations([]) | ||
.disabled(false) | ||
.omitted(false); | ||
|
||
imageTextSlideGroup | ||
.createField('hasPart') | ||
.name('Slides') | ||
.type('Array') | ||
.localized(false) | ||
.required(true) | ||
.validations([ | ||
{ | ||
size: { | ||
min: 1, | ||
max: 3 | ||
} | ||
} | ||
]) | ||
.disabled(false) | ||
.omitted(false) | ||
.items({ | ||
type: 'Link', | ||
validations: [ | ||
{ | ||
linkContentType: ['imageTextSlide'] | ||
} | ||
], | ||
linkType: 'Entry' | ||
}); | ||
|
||
const story = migration | ||
.editContentType('story'); | ||
|
||
story | ||
.editField('hasPart') | ||
.items({ | ||
type: 'Link', | ||
validations: [ | ||
{ | ||
linkContentType: ['embed', 'imageComparison', 'imageTextSlideGroup', 'imageWithAttribution', 'link', 'richText'] | ||
} | ||
], | ||
linkType: 'Entry' | ||
}); | ||
}; |