30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|||
|
|
|
||
|
|
// Adds optional English counterparts to the manually-authored Italian fields,
|
||
|
|
// on the same record (same slug, same cover, same category, same
|
||
|
|
// publishedAt) — see docs/content-model.md. An article/category with no
|
||
|
|
// translation yet simply leaves these blank; nothing else changes.
|
||
|
|
migrate((app) => {
|
||
|
|
const articles = app.findCollectionByNameOrId('articles')
|
||
|
|
articles.fields.add(
|
||
|
|
new TextField({ name: 'titleEn', max: 160 }),
|
||
|
|
new TextField({ name: 'contentEn', max: 10000 }),
|
||
|
|
new TextField({ name: 'coverAltEn', max: 200 })
|
||
|
|
)
|
||
|
|
app.save(articles)
|
||
|
|
|
||
|
|
const categories = app.findCollectionByNameOrId('categories')
|
||
|
|
categories.fields.add(new TextField({ name: 'nameEn', max: 160 }))
|
||
|
|
app.save(categories)
|
||
|
|
}, (app) => {
|
||
|
|
const articles = app.findCollectionByNameOrId('articles')
|
||
|
|
articles.fields.removeByName('titleEn')
|
||
|
|
articles.fields.removeByName('contentEn')
|
||
|
|
articles.fields.removeByName('coverAltEn')
|
||
|
|
app.save(articles)
|
||
|
|
|
||
|
|
const categories = app.findCollectionByNameOrId('categories')
|
||
|
|
categories.fields.removeByName('nameEn')
|
||
|
|
app.save(categories)
|
||
|
|
})
|