@kontent-ai/smart-link
Version:
Kontent.ai Smart Link SDK allowing to automatically inject [smart links](https://docs.kontent.ai/tutorials/develop-apps/build-strong-foundation/set-up-editing-from-preview#a-using-smart-links) to Kontent.ai according to manually specified [HTML data attri
38 lines • 1.77 kB
JavaScript
/**
* Builds a URL that opens the specified content item in the Kontent.ai web application editor.
*/
export function buildKontentItemLink(params) {
return `https://app.kontent.ai/goto/edit-item/project/${params.environmentId}/variant-codename/${params.languageCodename}/item/${params.itemId}`;
}
function buildElementLink(params) {
return `${buildKontentItemLink({ environmentId: params.environmentId, languageCodename: params.languageCodename, itemId: params.itemId })}/element/${params.elementCodename}`;
}
function buildComponentElementLink(params) {
return `${buildKontentItemLink({
environmentId: params.environmentId,
languageCodename: params.languageCodename,
itemId: params.itemId,
})}/component/${params.contentComponentId}/element/${params.componentElementCodename}`;
}
/**
* Builds a URL that opens a specific element within a content item in the Kontent.ai web application editor.
* This function can handle both regular content elements and elements within content components.
* If an element is within a component, 'contentComponentId' must be provided.
*/
export function buildKontentElementLink(data) {
return 'contentComponentId' in data
? buildComponentElementLink({
environmentId: data.environmentId,
languageCodename: data.languageCodename,
itemId: data.itemId,
contentComponentId: data.contentComponentId,
componentElementCodename: data.componentElementCodename,
})
: buildElementLink({
environmentId: data.environmentId,
languageCodename: data.languageCodename,
itemId: data.itemId,
elementCodename: data.elementCodename,
});
}
//# sourceMappingURL=link.js.map