Slide 125
Slide 125 text
module.exports = function (migration) {
const conference = migration.createContentType('conference')
.name('Conference/Meetup')
.displayField('name')
conference.createField('name').type('Symbol').required(true).name('Conference/Meetup name')
conference.createField('country').type('Symbol').required(true).name('Country Code')
conference.createField('city').type('Symbol').required(true).name('City')
const event = migration.editContentType('event')
event.createField('conference')
.name('Conference')
.type('Link')
.linkType('Entry')
.validations([
{
"linkContentType": ['conference']
}
])
migration.deriveLinkedEntries({
contentType: 'event',
from: ['name', 'country', 'city'],
toReferenceField: 'conference',
derivedContentType: 'conference',
derivedFields: ['name', 'country', 'city'],
identityKey: async (from) => {
return from.name['en-US']
// remove year
.replace(/\s(\d{2,4}|#\d+)/g, '')
// clear spaces
.replace(/\s/g, '-')
// clear "weird characters"
.replace(/(,|\/|\\|:|\.|\(|\))/g, '')
.toLowerCase()
},
deriveEntryForLocale: async (inputFields, locale) => {
return {
name: inputFields.name[locale].replace(/\s(\d{2,4}|#\d+)/g, ''),
country: inputFields.country[locale] || 'N/A',
city: inputFields.city[locale] || 'N/A'
}
}
})
event.moveField('conference').afterField('name')
event.deleteField('country')
event.deleteField('city')
}
LOC
48
REQUESTS
382
ENTRIES
CREATED
88
ENTRIES
UPDATED
96