Import content model
Is this page helpful?
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});
const response = client.addContentTypeSnippet()
.withData(builder => {
return {
name: "Metadata",
codename: "metadata",
elements: [
builder.textElement({
name: "Title",
codename: "title",
type: 'text'
}),
builder.textElement({
name: "Keywords",
codename: "keywords",
type: 'text'
}),
builder.textElement({
name: "Description",
codename: "description",
type: 'text'
})
]
};
})
.toPromise();
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});
const response = client.addTaxonomy()
.withData(
{
name: 'Blogpost topic',
codename: 'blog_topic',
terms: [
{
name: 'Sport',
codename: 'sport',
terms: [
{
name: 'Soccer',
codename: 'soccer',
terms: []
},
{
name: 'Ice hockey',
codename: 'hockey',
terms: []
},
{
name: 'Rugby',
codename: 'rugby',
terms: []
}
]
},
{
name: "Technology stack",
codename: "tech",
terms: [
{
name: "JavaScript",
codename: "js",
terms: []
},
{
name: "C#",
codename: "c",
terms: []
},
{
name: 'MVC',
codename: 'mvc',
terms: []
}
]
}
]
}
)
.toPromise();
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});
const response = client.addContentType()
.withData(builder => {
return {
name: 'Blogpost',
codename: 'blogpost',
content_groups: [{
name: 'Content',
external_id: 'content'
},
{
name: 'Metadata',
external_id: 'metadata'
},
{
name: 'Topic',
external_id: 'topic'
}
],
elements: [
builder.textElement({
name: 'Title',
type: 'text',
content_group: {
external_id: 'content'
},
}),
builder.assetElement({
name: 'Image',
type: 'asset',
content_group: {
external_id: 'content'
},
}),
builder.richTextElement({
name: 'Blog content',
type: 'rich_text',
content_group: {
external_id: 'content'
},
}),
builder.snippetElement({
snippet: {
'codename': 'metadata'
},
type: 'snippet',
codename: 'metadata',
content_group: {
external_id: 'metadata'
},
}),
builder.taxonomyElement({
taxonomy_group: {
'codename': 'blog_topic'
},
type: 'taxonomy',
codename: 'taxonomy',
content_group: {
external_id: 'topic'
}
})
]
};
})
.toPromise();