migrate
Migrate the Data payload to the latest shape, automatically transforming deprecated data.
import { migrate } from "@measured/puck";
migrate(legacyData);
Migrations
Root data to props
Migrates any props stored on root data to the props
object.
Before
{
"root": {
"title": "Hello, world"
}
}
After
{
"root": {
"props": { "title": "Hello, world" }
}
}
DropZones to slots
Migrates all DropZone data from zones
to inline slots. Requires matching slots to be provided via the config
arg. See the DropZone to slots migration guide for more information.
Before
{
"content": [
{
"type": "Grid",
"props": {
"id": "Grid-12345"
}
}
],
"zones": {
"Grid-12345:items": [
{
"type": "HeadingBlock",
"props": {
"id": "Heading-12345",
"title": "Hello, world"
}
}
]
}
}
After
{
"content": [
{
"type": "Grid",
"props": {
"id": "Grid-12345",
"items": [
{
"type": "HeadingBlock",
"props": {
"id": "Heading-12345",
"title": "Hello, world"
}
}
]
}
}
]
}
Args
Param | Example | Type | Status |
---|---|---|---|
data | { content: [{type: "Heading", props: {} }]} | Data | Required |
config | { components: {} } | Config | - |
data
The legacy data you want to transform.
config
Provide your configuration. Optional.
Returns
The updated Data object.