Skip to content

Commit

Permalink
CTC-2272 Update migration samples
Browse files Browse the repository at this point in the history
  • Loading branch information
jancerman committed Jul 18, 2024
1 parent ef76670 commit 1195728
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
const migrationItems: MigrationItem[] = [];
// 2. Map exported files to MigrationAssets
const migrationAssets: MigrationAsset[] = [];
// 3. Import the exported and mapped data into Kontent.ai
// 3. Import the mapped data into a Kontent.ai project
await importAsync({
data: {
assets: migrationAssets,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { MigrationAsset } from "@kontent-ai/migration-toolkit";
import { readFileSync } from "fs"; // Only if loading local data
import { readFileSync } from "fs"; // Only if using local data

const coverAsset: MigrationAsset = {
// You can load the data from anywhere, not just from the filesystem
// You can read the data from anywhere, not just from the filesystem
binaryData: readFileSync("./movies/posters/warrior.jpg"),
// Ensure a unique asset codename. Check https://kontent.ai/learn/rules-for-codenames
// This codename is used to reference the asset in the MigrationItem object
codename: "warrior_teaser",
// Name the binary file linked to the asset
filename: "warrior_teaser.jpg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ const movie: MigrationItem<MovieType> = {
type: { codename: "movie" },
workflow: { codename: "default" },
},
// Migrate up to 2 versions - latest and published. This is optional. Typically, you'd only migrate a single version of your content.
// Specify up to 2 versions of the variant - latest and published.
// The latest version can be in any workflow step.
versions: [
{
workflow_step: {
// Tip: You can have the item published during the import or use any other workflow step
// You can publish the variant during the import, or use any other workflow step
codename: "published",
},
elements: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { MigrationItem } from "@kontent-ai/migration-toolkit";

// MigrationItem defines a localized variant of a content item
const migrationItem: MigrationItem = {
// Variant's metadata
system: {
// Name the localized variant
// Name the content item. Item name is shared for all variants.
name: "My content item",
// Generate a unique content item codename
codename: "my_content_item",
// Assign the item (and all its variants) to a collection
// Assign the item to a collection
collection: { codename: "default" },
// Specify the variant's language
language: { codename: "en_us" },
// Specify the content type
type: { codename: "article" },
// Assign the variant to a workflow
// Assign the item to a workflow
workflow: { codename: "default" },
},
versions: [
Expand Down

0 comments on commit 1195728

Please sign in to comment.